Why that constructor, when I got other unparamterized?
Why in this code when I pass by value, there isnt invoking of the constructor of class B?
Code:#include <iostream> using namespace std; class B { public: B() { cout<<"test"; } int n; }; class test { private: int y; public: int z; test() { y=1; } test(B object) { y=object.n; } void print_y(); }; void test::print_y() { cout<<y<<endl; } int main() { B ob2; B ob3; cout<<"Put whatever you want"; cin>>ob2.n; test ob1(ob2); ob1.print_y(); system("PAUSE"); }




Reply With Quote
