Here’s the declaration:
class a{
public:
void print_fib(int x){
printf("%d\n",b::getfib(x));
};
};
class b{
public:
void init(); //calculate the Fibonacci numbers, save them in `fib[]`
int getfib(int x);
private:
int fib[10];
};
class c{
private:
a ca;
b cb;
};
How can I access cb.getfib() from ca.print_fib()?
If you pass
thisto ca and cb, you can use it to access cb and ca respectively.