Here is the code that I worked with:
The copy constructor is made to make deep copy of the object. So to make sure that the members of the class test (c,d) exist I printed their values in the function (no matter the printed text is non-understandable, I can still change their values (for ex. object.c=5 or object.d=33) so they obviously exist.Code:#include <iostream> using namespace std; class test { int c; friend void funkcija(test); public: int d; test(){ cout<<"Unparametrized constructor."<<endl;} test(const test &objekat) { cout<<"Copy constructor called."<<endl; } }; void funkcija(test objekat){ cout<<objekat.c<<endl; cout<<objekat.d; } int main() { test ob; funkcija(ob); system("PAUSE"); return 0; }




Reply With Quote
