So what do you have here:
class A { B title; }
Without a constructor definition for class A (as shown by Lucian Grigore), the title will be initialized as: B title();
You can work like this:
A::A():title(B("Hello world")) // Or by adding non parametric constructor: class B { B(){ } B( const char *str){ } }
The object header (in the document) is already initialized, and you can no longer call the constructor, but you can still use the syntax: document.title(...) by declaring and defining operator() , but it will no longer be a constructor:
class B { const B& operator()(const char *str){ cout << str; return *this; } }
source share