Class And Object In C++
It is a container, which holds data and functions
Class contains:
1. Functions
2. Data (variables)
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();
}
#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
Hobby: Invention