ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
There is small doubt about the below program
A(const A& src)
cout <<"Copy C'to!"<<endl;
cout << "Worked!"<<endl;
A a = A();
ifstream obj = ifstream("notepad.txt");
when we create a object like A a = A(); , according to me, this should create temporary object and then copy C'tor Should be called but this has not happened but if i make the copy C'tor of class A as private (even though it is not called or used), g++ error throws for statement A a = A();
If i create a ifstream object like above then g++ compiler throws an error like below :
My concern here is if we create a object like A a = A(); why the copy C'tor should be accessible if even it is not called and consequently why for ifstream it is required if Copy C'tor is not called for user defined class (Trying to make it generic)