reffering to function from one class in another

Hi,
I have a problem with reffering to function which is in another class from another file.
e.g
I have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class A 
{
...
public:
void function1();
...
}
void A::function1()
{}

class B
{
...
public:
void function2();
...
}
void B::function2()
{
function1()
}



function1 is a class function. You have to get an object of that class, and then call the function in that object.

1
2
3
4
void B::function2(A theObjectYouWantToCallTheFunctionOn)
{
theObjectYouWantToCallTheFunctionOn.function1();
}


or

1
2
3
4
5
void B::function2()
{
A theObjectYouWantToCallTheFunctionOn;
theObjectYouWantToCallTheFunctionOn.function1();
}
Topic archived. No new replies allowed.