Hey everyone,
So I am having a problem with this method.
How would I call this type of method in another class or function?Code:int AddToList( const Passenger& p, int seatNum )
If you need anymore code I will provide it.
Thanks in advance!
Printable View
Hey everyone,
So I am having a problem with this method.
How would I call this type of method in another class or function?Code:int AddToList( const Passenger& p, int seatNum )
If you need anymore code I will provide it.
Thanks in advance!
Hello XNOViice this functions has as 1st argument a reference and as 2nd an integer... How did you call it and it didn't work? :)
Welcome to forum by the way :D
Well the way I am trying to do is
Thanks for welcoming me also!Code:void RandomMethod()
{
list.AddToList(p.methodname,3);
}
We need to see the types of everything here and/or the error messages you are getting.
Ok so error 1 is "'p': undeclared identifier"
next is "left of '.ReadName' must have class/struct/union"
I guess that methoname returns a string but you want as first argument an object (a passenger). The second argument seems ok.
What is list? Global? Provide more code please :)
No I got it. I just needed to declare passenger in the class so I could reference to it. *facepalm* but thanks for the help!
Well, I am glad you found the solution.I would suggest you to post the solution here so that others that may have the same or similar problem as you can help themselves :)
And so that we can check that your solution to the problem is indeed correct...
You might check over here, where it was cross-posted.
http://cboard.cprogramming.com/gener...s-posters.html
At least be aware of this.
That was what I was missing
Code:void randomMethod()
{
solution->Passenger p
list.AddToList(p.methodname,3);
}
To me it is not clear but OK.
This is hardly OK. A member function of a class is coupled to an instance. That is, the function should get or mutate the instance whose function you call.
Right now, you are just saying that you need to create something, get some of its data, then destroy it. That makes no sense.