Back To C++ Constructors & Destructors
//program to demonstrate example of class student with data members (rollno, name, marks, clas) and contains member functions (showdata), class also contains a default constructor which initializes the data members #include
#include
#include
class student { int rollno; char name[20]; int marks; int clas; public: student() //a default constructor { rollno=10; strcpy(name,"abcdef"); marks=90; clas=11; } void showdata() { cout<<"\nrollno of student is "<