Beruflich Dokumente
Kultur Dokumente
============================================
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
template<class type>
public:
List(){ }
List(int s)
{
maxSize=s;
a= new type[maxSize];
used=0;
}
/*===== Getters=====*/
int getUsed()
{ return used; }
int getMaxSize()
{ return maxSize; }
bool isEmpty()
{
return used==0;
}
bool isFull()
{
return used==maxSize;
}
private:
type *a;
int used;
int maxSize;
};
public:
/*===== Constructors =====*/
Student()
{
strcpy(name,"Unknown");
id=0;
marks=0;
}
void setId(int d)
{
id=d;
}
void setMarks(float m)
{
marks=m;
}
char *getName()
{
return name;
}
int getId()
{
return id;
}
float getMarks()
{
return marks;
}
private:
char name[30];
int id;
float marks;
};
void main()
{
int no;
cout<<"\nEnter the no of Students that you want to Add: ";
cin>>no;
List<Student>Ls(no);
char name[30];
int id;
float marks;
for(int i=1;i<=no;i++)
{
system("cls");
Student ob;
Ls.addObject(ob);
system("cls");
Student obj;
/*======= Showing Output=======*/
for(int j=0,k=1;j<Ls.getUsed(),k<=Ls.getUsed();j++,k++)
{
cout<<"\nStudent "<<k<<endl;
Ls.getObject(j,obj);
cout<<"Name: "<<obj.getName()<<endl;
cout<<"Id: "<<obj.getId()<<endl;
cout<<"Marks: "<<obj.getMarks()<<endl;
cout<<endl<<endl;
}
http://www.ravianeducation.blogspot.com
FARHAN: 03008855006