By admin | January 25, 2008

A sample Class Structure in C++

A simple Class Structure is explained for the beginners. This is meant for learning C++

#include<iostream.h>

class try1

{

private:

        char name[20];

        int age;

        public:

        void inputdata()

        {

                cout<<”Enter yyour name”<<endl;

                cin>>name;

                cout<<”Enter yyour age”<<endl;

                cin>>age;

        }

        void displaydata()

        {    

     cout<<”Yyour name is:”<<name<<endl;

                cout<<”Yyour age is :”<<age<<endl;

        }

 };  //end of class

 void main()

 {

        try1 t1;

        t1.inputdata();

        t1.displaydata();

               }

Digg Facebook Technorati Bloglines

Email This Post Email This Post
Topics: Languages |



Leave a Comment

Name:

E-Mail :

Website :

Comments :

Ad

Calendar

January 2009
M T W T F S S
« Oct «-»  
 1234
567891011
12131415161718
19202122232425
262728293031  

Search

Polls

  • Who will rule the world?

    View Results

    Loading ... Loading ...