-
Need help with class
I have a question about classes.
here is my situation. I have 2 classes in 2 separate header files.
Code:
class a {
function
int x(int);
void y();
};
function void z();
class b {
function r;
};
function s;
class a in a.h file. All class a functions are in a.cpp file
I have
int a::x(g)
class b c;
Inside this function, I want to call r,s,y and z.
The question is How can I call these 4 functions.
-
Please have a look at how to define functions in C++:
Code:
<return type> <function-name>(<arguments>);
If the functions you implemented are not static, you first need to create an object of that class before you can call any functions.
Code:
A *objectOfA = new A();
objectOfA->x(10);
// ...
// delete object afterwards
delete objectOfA;
-
Why do you need to call new?
This should suffice:
Code:
A ObjectOfA;
ObjectOfA.x(10);