Hi everyone,
I got problem understanding classes in C++. I hope some one would help me with this.
Lets say I have x.h file where class x is declared with its private and public members. Also I have x.cpp file where the body of each function from class x is located.
I have another y.h and y.cpp file done the same way as previous.
Also I have main.cpp file that contains main function.
I have to create z.h file and z.cpp file that contains z class. This class will have its private and public members as well.
Now, because members in calss x and class y should not be change at any time plus private members from class z should not be change I have to come up with the way how to use them. I have to come up with functions in calss z that would get members from thiferent classes and private members from z calss.
It shouls look something like this
Code:
class z {
int a;
int b;
public:
z ();
void someFunctions();
int geta() { return a;}
int getb() {return b;}
}
I guess this is how would I get private parts from same class without changing them. But I dont understand how can I get members from other classes (class x and y). It has to be part of class z and it would be something like x & getx();
and y & gety();
I would apritiated if anyone can help me with this. If you need more information about what I'm talking about let me know I will try to go in more details.
I'm tring to understand the consept of this.