Reputation: 55
I have two classes A and C, where I need to have object of C in class A as a private member. This is the basic structure I have and I have following issues:
1. How can I create the itsC object in constructor?
2. I am getting following error 'function call missing argument list' as shown below
C::C(String strc)
{
//do something
}
Class A
{
public:
A(String stra, String strb) ;
~A();
C GetC(); //method
private:
C itsC(String str1); //data member
}
A::A(String stra, String strb)
{
//create object itsC
//strb is needed for str1
}
C A::GetC()
{
return itsC; //error::function call missing argument list
}
Thanks.
Upvotes: 2
Views: 5183
Reputation: 75130
C itsC(String str1);
Is a member function declaration, not a data member. It should be
C itsC;
Then you can initialise it in A::A
A::A(String stra, String strb) : itsC(stra) { }
Upvotes: 2