#include "a.hpp"
class B {
public:
float stuff(A& a);
};
b.cpp
1 2
#include "b.hpp"
float B::stuff(A& a) { a.stuff(); return...}
How should call stuff(A& a) function in another place of the B class? when I Call float take = stuff(A& a);
I Get this error: Symbol 'a' could not be resolved
class A {
public:
void foo();
};
void A::foo() {}
class B {
public:
float stuff(A& a);
};
float B::stuff(A& a) {
a.foo();
return 0;
}
int main()
{
A aa;
B bb;
bb.stuff(aa);
}
That isn't valid syntax. But I'm not sure what your question is. float stuff(A& a); is a member function of the B class. Yes, you can call it from within the B class, but your B class only has one function to begin with, so you'd just be calling it recursively.
Sorry about my language, my B class has another function and I want to use float stuff(A& a); in it but I get this error: Symbol 'a' could not be resolved
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class B {
public:
float stuff(A& a);
void reuse();
};
float B::stuff(A& a) {
a.foo();
return 0;
}
void B:: reuse(){
float take = stuff(A& a);
}
Firstly, stop putting everything into different files. You won't benefit from this until your project is large enough that it must be organized this way.
Secondly, tell us about the situation that prompted this question. What are you doing, and why do you think this is the solution?