Free C++ course with real-time projects Start Now!!
Program 1
// Program for Cnstructor #include<iostream> #define clrscr() system("cls") using namespace std; class Test { int n; public: Test() { n=100; } void incr(); void display(); }; void Test::incr() { ++n; } void Test::display() { cout<<n; } int main() { Test T1,T2; T1.incr(); T1.incr(); T1.incr(); cout<<"\nT1 Object"; T1.display(); cout<<"\nT2 Object"; T2.display(); }