Page 223 - DCAP404 _Object Oriented Programming
P. 223

Object-oriented Programming




                    Notes          class  academic:  public  student  {
                                   private:
                                   char  stream;
                                   public:
                                   void  getdata  (  );
                                   void  display  (  );
                                   }  ;
                                   void  student::  getdata  (  )
                                   {
                                          cout<<  “enterrollno\n”;
                                          cin>>  rollno;
                                          cout  <<“enter        name  \n”;
                                          cin  >  >  name;
                                   }

                                   void  student::  display  (  )
                                   {
                                          cout<<  “the  student’s  roll  number  is  “<<rollno<<“and  name  is”
                                   <<name;
                                          cout<<  endl;
                                   }
                                   void  academic  ::  getdata  ()
                                   {
                                          cout<<  “enter  stream  of  a  student?  \n”;
                                          cin  >>stream;
                                   }
                                   void  academic  ::  display  ()  {
                                          cout<<  “students  stream  \n”;

                                          cout  <<stream<<  end!;
                                   }
                                   void  main  (  )
                                   {
                                          student  *ptr;
                                          academic  obj;
                                          ptr=&obj;
                                          ptr->getdata  ();
                                          ptr->display  ();
                                          getche  (  );
                                   }




          216                               LOVELY PROFESSIONAL UNIVERSITY
   218   219   220   221   222   223   224   225   226   227   228