c++ - Private variable needs to be initialized only in constructor. How? -


I have a code that is called Foo with a constructor in which arguments, and Another class bar a foo private variable

  square fu {public: with fu (string); } Square Bar {Public: Bar () {This-> Foo = Foo ("test")} private: Fu Fu; }  

However, when I try to compile it, I get a compilation error that Foo :: Foo () is not a constructor. It seems that the personal variable is started in the foo class bar before getting the specified value in the constructor.

How do I create a personal variable that waits for my constructor to start?

If you do not do this in an initial list, your code will be assigned to the default constructor for that object. Will call.

  Bar :: Bar (): foo ("test") {// stuff}  

Comments