Class Constructor and Destructor for this Class

 #include<iostream>

using namespace std;

class Student

{

string name;

public:

Student(){

    name = "Vaibhav Yadav";

    cout<<"Constructor of Student Class has been Called"<<endl;

    cout<<"Student Name is: "<<name<<endl;

}

~Student(){

    cout<<"---Destructor Of Student Class has been called---"<<endl;

    cout<<"---Memory for 'obj name' has been deallocated and memory has been released---"<<endl;

}

};


main()

{

Student stu;

return 0;

}


Program to demonstrate the friend function and friend class in c++

 #include<iostream>

using namespace std;

class Student

{

string Stu_name = "Vaibhav Yadav";

string branch = "Information Technology";

friend class MMMUT;

friend void studisplay(Student);

};

void studisplay(Student t){

    cout<<endl<<"Student branch is: "<<t.branch;

}

class MMMUT

{

public:

void display(Student t)

{

cout<<endl<<"Student Name is: "<<t.Stu_name;

}

};

main()

{

Student stu;

MMMUT clgstu;

clgstu.display(stu);

studisplay(stu);

return 0;

}


Employee Details Using Structure (c++)

 #include <iostream>

#include <string>

using namespace std;

struct Employee{

    int Emp_ID, age;

    string fname, lname, department;

    char sex;

};


int main() {

  struct Employee em;

  cout<<"Enter Your Employee_ID: ";

  cin>>em.Emp_ID;

  cout<<"Enter Your Employee Age: ";

  cin>>em.age;

  cout<<"Enter Your First Name and Last Name: ";

  cin>>em.fname>>em.lname;

  cout<<"Enter Employee Department: ";

  cin>>em.department;

  cout<<"Enter Your Sex ";

  cin>>em.sex;

  cout<<endl;

  cout<<"Employee ID is:"<<em.Emp_ID<<endl;

  cout<<"Employee Age is: "<<em.age<<endl;

  cout<<"Employee First Name is "<<em.fname<<endl<<"Employee Last Name is " <<em.lname<<endl;

  cout<<"Employee Department: "<<em.department<<endl;

  cout<<"Employee Sex is: "<<em.sex<<endl;

    return 0;

}

Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...