//simple program using class
//**************************
#include<iostream>
#include<string>
using namespace std;
class info
{
private: //private part of the class
int roll_no;
string name;
public: //public part of the class
void in() //this function is used for enter the data
{
cout<<"enter your roll number:";
cin>>roll_no;
cout<<"enter your name:";
cin>>name;
}
void out()//this function is used for print the data
{
cout<<"your roll number is:"<<roll_no<<endl;
cout<<"your name is:"<<name<<endl;
}
};
int main()
{
info f; //making object of the class
f.in();
f.out();
}
No comments:
Post a Comment