Thursday, January 19, 2023

DESTRUCTOR IN C++ (2)

 #include<iostream>

using namespace std;


class cl

{

int a;

public:

  cl();

  cl(int x);

  void output();

  ~cl();

};

cl::cl()

{

a=10;

cout<<"overloading"<<a<<endl;

}

cl::cl(int x)

{

a=x;

cout<<"overloading"<<a<<endl;

}

void cl::output()

{

cout<<a<<endl;

}

cl::~cl()

{

cout<<"destructing"<<a<<endl;

}


void f( cl ob3)

{

cout<<"monday"<<endl;

}

int main()

{

cl ob(100),ob1,ob2(50),ob3(30);

cout<<"sunday"<<endl;

f(ob3);

cout<<"friday"<<endl;

}

No comments:

Post a Comment

A physicist confesses that the electron is round and that Jesus rose from the dead. (Bengali)

একজন পদার্থবিজ্ঞানী স্বীকার করেন যে ইলেকট্রন গোলাকার এবং যিশু মৃতদের মধ্য থেকে পুনরুত্থিত হয়েছিলেন। আমার নিজের বিশ্বাস প্রমাণ দ্বারা প্রভাব...