




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















Class Class is a user defined data type.
Public Interface
Yes you can use user defined data type as a member of the class Class can contain objects.
Example
Person :: Person ( char * name , char * address , int day, int month, int year ) : Date ( int month , int day , int year )
Constructor Date :: Date ( int day , int month , int year ) { cout << “Inside Date constructor ” ; } Person :: Person ( char * name , char * address ,int day , int month , int year ) : Date ( month , day , year ) { cout << “Inside Person constructor” ; }
Example class Column { private : int size ; public : Column ( ) { cout << "Column Created" << endl ; } void display ( ) ; void set ( int ) ; ~ Column ( ) { cout << "Column destroyed" << endl ; } } ; Docsity.com
Example class Row { private : int size ; Column col ; public : void set ( int ) ; Row ( ) { cout << "Inside Constructor for object Row" << endl ; } ~ Row ( ) { cout << "Row destroyed" << endl ; } void display ( ) ; } ; Docsity.com
main( ) { Matrix m ; m.display ( ) ; } Example
Column Created Inside Constructor for object Row Matrix Created …. Matrix Destroyed Row Destroyed Column Destroyed Output
const Date dateOfBirth ;
Structure inside a structure