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

               }

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>