C++ Simple Program with Class
#include<stdio.h>
#include<iostream.h>
class student
{
char name[20];
int age;
public:
void getdata()
{
cin>>name;
cin>>age;
}
void putdata()
{
cout<<name;
cout<<age;
}
}a;
int main()
{
clrscr();
a.getdata();
a.putdata();
getch();
return (0);
}
what is public?
ReplyDeletethe public keyword specifies that those members are accessible from any function.
ReplyDelete