What is The Rule of Three?

Answer

C++ treats variables of user-defined types with value semantics. This means that objects are implicitly copied in various contexts, and we should understand what "copying an object" actually means.

Let us consider a simple example:

class person
{
    std::string name;int age;public:

    person(const std::string& name,int age): name(name), age(age){}};int main(){
    person a("Bjarne Stroustrup",60);
    person b(a);// What happens here?
    b = a;// And here?}

(If you are puzzled by the name(name), age(age) part, this is called a member initializer list.)

All c++ Questions

Ask your interview questions on c

Write Your comment or Questions if you want the answers on c from c Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---