c++ creating class person with two private variable name and age and two public functions

//create class person with two private variable name and age and two public fn void get data and void put data

#include<iostream>
using namespace std;
class person
{
char name[50];
int age;
public:
void getdata();
void putdata();
};

void person::getdata()
{
cout<<“Enter the name : “;
cin>>name;
cout<<“Enter the age”;
cin>>age;
}

void person::putdata()
{
cout<<“Name : “<<name;
cout<<endl<<“age : “<<age;
}

int main()
{
person m;
m.getdata();
m.putdata();
return 0;

}

OUTPUT-
Enter the name : bum
Enter the age21
Name : bum
age : 21

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat