Thursday, 6 March 2014

Example For Array Of Objects

#include<iostream.h>
Class Test
{
int no,mark;
Public:
    void Input();
    void  Display();
}

void main()
{
Test Ob[50];
 Cout<<"Enter No And Marks For 50 Students\n";
for(int i=0;i<50;i++)
  {
   Ob[i].Input();
   }
Cout<<"NO  "<<"   "<<"MARKS\n" ;
cout<<"-------------------------";
for(int i=0;i<50;i++)
   {
      Ob[i].Display();
    } 
}

Void Test::Input()
{
cin>>no>>mark;
}

void Test::Display()
{
 cout<<no<<"\t\t\t"<<mark<<"\n";
}

No comments:

Post a Comment