CLASS AND OBJECT IN C++

Maha

Class And Object In C++

     It is a container, which holds data and functions
Class contains:
     1. Functions
     2. Data (variables)

Program:

include<iostream.h>
#include<string.h>
class hobby
{
char name[25];
char hobby[25];
public:
void show()
{
strcpy(name,”Kalam”);
strcpy(hobby,”invention”);
cout << "\nName: " << name;
cout << "\nHobby: " << hobby;
}
};
void main()
{
hobby obj;
obj.show();
}

Output:

Name : Kalam
Hobby: Invention
Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send