User Profile

Collapse

Profile Sidebar

Collapse
Micko1
Micko1
Last Activity: Oct 30 '07, 11:09 PM
Joined: Sep 16 '07
Location: Australia
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Micko1
    replied to overloading <<
    in C
    Thankyou both for the reply.

    I misunderstood the definition for the overloading teplate, I have made the changes and I'm still getting the memory address.

    I think it is because I am using a pointer:

    Code:
    ostream& operator << (ostream &out, const room * &currentPlayerLocation)
    {
    	out << currentPlayerLocation->roomDescription;
    	return out;
    }
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to overloading <<
    in C
    Ive played around with various formats with this method.

    Surely there has to be a way
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to overloading <<
    in C
    thankyou for the reply.

    so you say to make a function like:

    "ostream& operator<< (ostream&, const yourClass&);

    would this equate to:

    string& operator<<(stri ng&, room const * &currentPlayerL ocation);

    if so, it doesent work. It puts out error message that it has too many parameters....
    See more | Go to post

    Leave a comment:


  • Micko1
    started a topic overloading <<
    in C

    overloading <<

    hi there,

    I have an issue when overloading <<.

    Code:
    	string operator << (room * &currentPlayerLocation);
    
    
    string room::operator << (room * &currentPlayerLocation)
    {
    	return roomDescription;
    
    }
    when I call this function:

    cout << currentPlayerLo cation;

    Its cout's the actual memory address...
    See more | Go to post

  • Micko1
    replied to classes, inheritance and functions
    in C
    hmm I have just done this, and it seems while it works for 1 derived class, the other just calls the base class function still.

    Any ideas?...
    See more | Go to post

    Leave a comment:


  • Micko1
    started a topic classes, inheritance and functions
    in C

    classes, inheritance and functions

    Hi there,

    I seem to be having some trouble with my code.

    I have a base class a
    Pointer a

    Derived class b
    Pointer b

    Another derived class called c
    Pointer c

    All 3 have a function called setX, but when I try to c->setX it will always use the base classes setX.

    How can I make it only call the setX function for that class?

    ...
    See more | Go to post

  • Micko1
    replied to Some help with Pointers please
    in C
    all fixed :)

    Thanks for all the help!
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to Some help with Pointers please
    in C
    Thanks for the reply, I appreciate it :)

    Firstly, the semicolin was a typo :)

    Even when I do as you say, I still get this error, I'm unsure what I'm getting wrong..
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to Some help with Pointers please
    in C
    ok cool, thankyou for the replies, I modified the fuction to check if the pointers are NULL, so it doesent keep looping :)

    I have another question:

    Code:
    int main()
    {	
    	int movesLeft = 20;
    
    	room * currentPlayerLocation;
    	room currentRoom;
    
    	currentPlayerLocation = currentRoom;
    
    	//room * currentPlayerLocation = new room ("currentRoom;");
    ...
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to Some help with Pointers please
    in C
    I have a class called "room" I have 10 rooms (room1 room2.......roo m10) the rooms are connected via pointers (North, South, East,West). I have a function that creates all the rooms, and the code above is a section from the function that connects the rooms (room1 North leads to room2 and room2 South points to room1).

    What I'm trying to achieve is a 2 way connection (North points to room2 and south points to room1)
    ...
    See more | Go to post

    Leave a comment:


  • Micko1
    started a topic Some help with Pointers please
    in C

    Some help with Pointers please

    Hello,

    I am having some trouble with this function:


    Code:
    	
    void room::addConnection(string direction, room *x)
    {
    	if (direction == "north")
    	{
    		 north = x;
    	}
    }
    How can I make the connection both ways? For example I connect room1 with room2 (north) as shown above, but how can I make it that it automatically joins room2 with room1 (south)...
    See more | Go to post

  • I tried adding that command into my make file ( I think i did it right) but to no avail.

    this is my make file:



    Code:
    all: nurseryTest
    all: nursery
    clean:
    	rm *.o nurseryTest
    	rm *.o nursery
    	
    nursery.o: nursery.cpp nursery.h
    	g++ -c nursery.cpp
    
    nurseryTest.o: nursery.cpp nursery.h
    	g++ -c nurseryTest.cpp
    	
    nurseryTest:
    ...
    See more | Go to post

    Leave a comment:


  • I am unsure what you mean?

    It is just the regular Cygwin that you get off the website...

    Basically I need this program to compile in a unix environment...
    See more | Go to post

    Leave a comment:


  • The full error I am getting is:...
    See more | Go to post

    Leave a comment:


  • Thankyou for the replies.

    yes it has a main function....
    See more | Go to post

    Leave a comment:


  • ERROR: "undefined reference to `_WinMain@16'" when compiling in Cygwin

    Hello there :)

    I have been using Visual Studio on a program which I have just completed, however I need to have it compiling using a unix based compiler, when I try in cygwin, I get the following error:

    undefined reference to `_WinMain@16'

    I have tried searching for a workaround, although I am not a programming guru, and I find it difficult to comprehend the discussions on this topic :)

    ...
    See more | Go to post

  • Micko1
    replied to C++ Need help with array of objects
    in C
    Not a problem, understand 100%

    just to let the kind people that helped out, I solved the problem with a basic turn function.

    Thanks again...
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to C++ Need help with array of objects
    in C
    one question, depending on the location of the plants (inside or outside) determines how much sunlight level/hydration is gained or lost per turn (loops of menu)

    I seem to be having trouble with this... i can add a to a single plants sunlight and hydration no problem, but how to effect all plants each turn, depending on their location?

    start with 35 hydro/40 sun

    watering = +50 hydro

    per...
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to C++ Need help with array of objects
    in C
    I thankyou very much for the time you have taken to help me out!

    this is very close to the end product I was trying to achieve, apart from a few minor details.

    thankyou very much!...
    See more | Go to post

    Leave a comment:


  • Micko1
    replied to C++ Need help with array of objects
    in C
    thankyou for the reply, I really appreciate it!

    the switch I was basically writing off the top of my head at the time, and I have since corrected it.

    I could attach the other files, however I am unsure of how to do this on this forum.

    Due to the forum guidelines I don't want to just post up all the code(copy and paste)

    What should I do, just post up all the required code?

    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...