Basic C++ class and object program
This is a basic program of class and object C++ :
program :
#include <iostream>
using namespace std;
class age
{
int age;
char name[2];
public:
void get()
{
cout<<"enter your age and name: ";
cin>>age>>name;
}
void dis()
{
cout<<"name is "<<name<<",age is "<<age;
}
};
int main()
{
age a1;
a1.get();
a1.dis();
return 0;
}
output :
Comments
Post a Comment