#include <iostream>
#include <string>
using namespace std;


class Student
{
private:
    string name;
    string rollNo;

public:
    Student()
    {
        name = "Unknown";
        rollNo = "0";
        cout << "Default Constructor Called" << endl;
    }

    Student(string n, string r)
    {
        name = n;
        rollNo = r;
        cout << "Parameterized Constructor Called" << endl;
    }

    Student(const Student &s)
    {
        name = s.name;
        rollNo = s.rollNo;
        cout << "Copy Constructor Called" << endl;
    }

    void display()
    {
        cout << "Name: " << name << endl;
        cout << "Roll No: " << rollNo << endl;
    }

    ~Student()
    {
        cout << "Destructor Called for " << name << endl;
    }
};

int main()
{
    string name, rollNo;

    cout << "Enter Name: ";
    cin >> name;

    cout << "Enter Roll No: ";
    cin >> rollNo;

    cout << endl;

    Student student1;
    student1.display();

    cout << endl;

    Student student2(name, rollNo);
    student2.display();

    cout << endl;

    Student student3(student2);
    student3.display();

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: