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.

有帮助吗?

解决方案

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) { }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top