Complete-Preparation

πŸŽ‰ One-stop destination for all your technical interview Preparation πŸŽ‰

View the Project on GitHub

This pointer, shallow and deep copy

This pointer

This pointer can be used to,

Example:

class mobile
{
    string model;
    int year_of_manufacture;

public:
    void set_details(string model, int year_of_manufacture)
    {
        this->model = model;
        this->year_of_manufacture = year_of_manufacture;
    }
    void print()
    {
        cout << this->model << endl;
        cout << this->year_of_manufacture << endl;
    }
};

int main()
{
    mobile redmi;
    redmi.set_details("Note 7 Pro", 2019);
    redmi.print();
}

// Output:
// Note 7 Pro
// 2019

Shallow copy

Deep copy

Interview questions

Resources