0% found this document useful (0 votes)
2 views4 pages

Student CPP

The document contains a C++ program that defines two classes, Student and StudData, to manage student information including name, roll number, class, division, date of birth, blood group, contact address, telephone number, and driving license number. The program allows users to input data for multiple students, display their information, and count the total number of students entered. Memory management is handled through dynamic allocation and deallocation of resources in the constructor and destructor of the classes.

Uploaded by

Rutuja Mane
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Student CPP

The document contains a C++ program that defines two classes, Student and StudData, to manage student information including name, roll number, class, division, date of birth, blood group, contact address, telephone number, and driving license number. The program allows users to input data for multiple students, display their information, and count the total number of students entered. Memory management is handled through dynamic allocation and deallocation of resources in the constructor and destructor of the classes.

Uploaded by

Rutuja Mane
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

Assignment No: 3

Roll No : 67
Name: Mane Rutuja Santosh

source code:

#include<iostream>
#include<string.h>
using namespace std;

class StudData;

class Student{
string name;
int roll_no;
string cls;
char* division;
string dob;
char* bloodgroup;
static int count;

public:

Student()
{
name="";
roll_no=0;
cls="";
division=new char;
dob="dd/mm/yyyy";
bloodgroup=new char[4];
}

~Student()
{
delete division;
delete[] bloodgroup;
}

static int getCount()


{
return count;
}

void getData(StudData*);
void dispData(StudData*);
};

class StudData{
string caddress;
long int* telno;
long int* dlno;
friend class Student;

public:

StudData()
{
caddress="";
telno=new long;
dlno=new long;
}

~StudData()
{
delete telno;
delete dlno;
}

void getStudData()
{
cout<<"Enter Contact Address : ";
[Link]();
getline(cin,caddress);
cout<<"Enter Telephone Number : ";
cin>>*telno;
cout<<"Enter Driving License Number : ";
cin>>*dlno;
}

void dispStudData()
{
cout<<"Contact Address : "<<caddress<<endl;
cout<<"Telephone Number : "<<*telno<<endl;
cout<<"Driving License Number : "<<*dlno<<endl;
}
};

inline void Student::getData(StudData* st)


{
cout<<"Enter Student Name : ";
getline(cin,name);
cout<<"Enter Roll Number : ";
cin>>roll_no;
cout<<"Enter Class : ";
[Link]();
getline(cin,cls);
cout<<"Enter Division : ";
cin>>division;
cout<<"Enter Date of Birth : ";
[Link]();
getline(cin,dob);
cout<<"Enter Blood Group : ";
cin>>bloodgroup;
st->getStudData();
count++;
}

inline void Student::dispData(StudData* st1)


{
cout<<"Student Name : "<<name<<endl;
cout<<"Roll Number : "<<roll_no<<endl;
cout<<"Class : "<<cls<<endl;
cout<<"Division : "<<division<<endl;
cout<<"Date of Birth : "<<dob<<endl;
cout<<"Blood Group : "<<bloodgroup<<endl;
st1->dispStudData();
}

int Student::count;

int main()
{
Student* stud1[100];
StudData* stud2[100];
int n=0;
char ch;

do
{
stud1[n]=new Student;
stud2[n]=new StudData;
stud1[n]->getData(stud2[n]);
n++;
cout<<"Do you want to add another student (y/n) : ";
cin>>ch;
[Link]();
} while (ch=='y' || ch=='Y');

for(int i=0;i<n;i++)
{
cout<<"---------------------------------------------------------------"<<endl;
stud1[i]->dispData(stud2[i]);
}

cout<<"---------------------------------------------------------------"<<endl;
cout<<"Total Students : "<<Student::getCount();
cout<<endl<<"---------------------------------------------------------------"<<endl;

for(int i=0;i<n;i++)
{
delete stud1[i];
delete stud2[i];
}
return 0;
}

output:

You might also like