#include<iostream>
using namespace std;
class sample
{
char name[20];
int age;
static int section;
public:
void getdata()
{
cout<<"ENTER NAME AND AGE"<<endl;
cin>>name>>age;
}
static void getdata1()
{
cout<<"Enter section"<<endl;
cin>>section;
}
void display()
{
cout<<"name= "<<name<<endl;
cout<<"age= "<<age<<endl;
}
static void display1()
{
cout<<"section= "<<section<<endl;
}
};
int sample :: section;
int main()
{
sample s1,s2;
s1.getdata();
s2.getdata();
sample :: getdata1();
s1.display();
sample :: display1();
s2.display();
sample :: display1();
return 0;
}
using namespace std;
class sample
{
char name[20];
int age;
static int section;
public:
void getdata()
{
cout<<"ENTER NAME AND AGE"<<endl;
cin>>name>>age;
}
static void getdata1()
{
cout<<"Enter section"<<endl;
cin>>section;
}
void display()
{
cout<<"name= "<<name<<endl;
cout<<"age= "<<age<<endl;
}
static void display1()
{
cout<<"section= "<<section<<endl;
}
};
int sample :: section;
int main()
{
sample s1,s2;
s1.getdata();
s2.getdata();
sample :: getdata1();
s1.display();
sample :: display1();
s2.display();
sample :: display1();
return 0;
}
No comments:
Post a Comment