Friday, June 28, 2013

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);
}

2 comments:

  1. the public keyword specifies that those members are accessible from any function.

    ReplyDelete