Code goes first:
//.h file
class A
{
public:
A();
B makeB(int); //question 1
//protected:
struct B {
int _id;
B(int id);
}
};
//.cpp file
A::A()
{ cout<<"A ctor\n"; }
B A::makeB(int id) //question 2
{ return B(id); }
2 questions:
1.Should I put makeB() function after the definition of struct B?
2.In .cpp file, should prefix every B with A:: ?
PS:
1.If makeB function doesn’t deal with B instances, but B pointers or refs, can I put a forward decl of struct B in front of makeB? (I just don’t want put the definition of struct B in front of mem-funcs).
This compiles fine: