![]() |
|
#1
|
|||
|
|||
Passing two objects to another class functionHello I am trying to pass two objects to another class function, however I can't get this to work...
this is when I am calling the function whom I am passing the two objects from main. CPP / C++ / C Code:
this is the function definition which is located in the class .h CPP / C++ / C Code:
I am getting two errors... 3 C:\cplusplus\CarTicket\policeofficer.cpp In file included from policeofficer.cpp 39 C:\cplusplus\CarTicket\policeofficer.h variable or field `examineParkedCar' declared void any ideas on how to do this correctly? |
|||
|
#2
|
|||
|
|||
Re: Passing two objects to another class functionDoes your 'examineParkedCar()' return a value?
Perhaps you have a circular dependency issue. That is, one of your header files includes another header that includes the original header that includes the other header that includes... Without you showing the complete code we can only guess. |
|
#3
|
|||
|
|||
Re: Passing two objects to another class functionIt doesn't return anything.. here is the code..
this is main CPP / C++ / C Code:
this is policeofficer.h CPP / C++ / C Code:
and this is policeofficer.cpp CPP / C++ / C Code:
hope this is enough! thank you! =] |
|
#4
|
|||
|
|||
Re: Passing two objects to another class functionQuote:
CPP / C++ / C Code:
It should then compile fine. |
|
#5
|
|||
|
|||
Re: Passing two objects to another class functionActually.. now it gives me no errors.. however I cannot access the member functions of the objects that are being passed... i tried them passing as pointers too.. and the compiler does not recognize them...
|
|
#6
|
|||
|
|||
Re: Passing two objects to another class functionhere is my whole code again...
I cannot access the member functions of the two objects when I am passing them to PoliceOfficer class.... it does not recognize them.. any ideas? MAIN CPP / C++ / C Code:
This is ParkedCar class CPP / C++ / C Code:
ParkingMeter class CPP / C++ / C Code:
PoliceOfficer class CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
Re: Passing two objects to another class functionQuote:
Three things I can think of: 1. You used the forward declaration, but then tried to write the method examineParkedCar() inline inside your PoliceOfficer class. This won't do. If you want to do this, then you need to include the header files. Otherwise the compiler has no way of knowing that ParkedCar has this-and-this method and it does that-and-that. 2. You tried to access the methods with the indirect member access operator (->). Use '->' only with pointer types, otherwise use '.' . 3. You changed the parameters to pointers instead of references, but tried to access them with the direct member access operator (.) . But, it's only guessing. Without direct copy-pastes of the erorr messages there's no way of knowing. Quote:
EDIT: Here's a sample examineParkedCar() method: CPP / C++ / C Code:
And here's a sample run of your program with this: Code:
|
|
#8
|
|||
|
|||
Re: Passing two objects to another class functionahh.. I tried my code in my home pc and it works perfect now.. It didnt back when i was at work!
thanks alot!! =] |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| run script command on ns2.26 | newbie06 | Computer Software Forum - Linux | 66 | 16-Jan-2010 10:53 |
| Compiling C btrieve programs in VS 2005 | emanresu | C Programming Language | 1 | 16-Nov-2009 03:19 |
| Problem executing nam-1.13 | RodolfoAlvizu | Computer Software Forum - Linux | 20 | 28-Feb-2009 15:23 |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 19:23 |
| Box Class, need help again :( | TransformedBG | C++ Forum | 7 | 13-Nov-2006 15:11 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The