#include <iostream> using namespace std; class XYZ { public: XYZ() { cout << "const XYZ called"; } }; class ABC { public: ABC(XYZ xyz) { cout << "const ABC called"; } void print() { } }; int main() { ABC b(XYZ()); b.print(); } |
#include <iostream> using namespace std; class XYZ { public: XYZ() { cout << "const XYZ called"; } }; class ABC { public: ABC(int i, XYZ xyz) { cout << "const ABC called"; } void print() { } }; int main() { ABC b(1, XYZ()); b.print(); } |
Please don't post comments/corrections that are off-topic and spoil my thread. |