VUsolutions Transferred to AchiKhasi.com

From December 2011, this blog www.VUsolutions.blogspot.com is transferred to http://achikhasi.com/vu/ . So, you may visit http://achikhasi.com/vu/ for latest study related help.

Back to home VUsolutions

VUsolutions Fans Club [join us for MORE solutions]

VUsolutions on Facebook

CS201 Assignment # 4 Solution

Saturday, June 26, 2010 Posted In Edit This


Problem Statement: Student class

You are required to write a class named “Student “. Student class has the following data members
·
Name
·
Roll Number
·
Semester
·
CGPA

Student class should have
Default and overloaded constructors
Getter and setter functions
A display function that will display the values of data members of an object
You are required to create two objects of student class. One object should be initialized with default constructor, and second object should be initialized with overloaded constructor.
Then you should display the values of both objects using display() function.

Solution:-


#include 

using namespace std;
class Student{
private:
string name;
int rollNumber;
string semester;
double cgpa;

public:
Student(string n,int r,string s,double c )
{name=n;
rollNumber=r;
semester=s;
cgpa=c;
}
Student()
{name="";
rollNumber=0;
semester="Summer 2010";
cgpa=4.0;
}


string get_semester()
{return semester;
}
void set_semester(string n)
{semester=n;
}
void set_roll(int n)
{rollNumber=n;
}
int get_roll()
{return rollNumber;
}
void set_name(string n)
{name=n;
}
string get_name()
{return name;
}
void set_cgpa(double n)
{cgpa=n;
}

double get_cgpa()
{return cgpa;
}
 void print()
{cout<<"Student Information\n";
cout<<"Name: "<
<<<<<<<<<="" <="" <="" <="" a.print();="" a;="" b("name",2345,"spring="" b.print();="" cgpa<<<<"current="" cout<<"roll="" cout<<"semester:="" gpa:="" int="" iostream="" main()="" name<<<<="" }=""><

Please do make changes in these assignment otherwise every one who copy this assignment as it is will awarded zero marks 

Back to home VUsolutions

Shaadi.com: Just create ur account & find ur partner or EARN money, its reall & EASY

VUsolutions Followers (Join NOW and Get Extra Benefits)

Install LATEST toolbar having lot of features - GET solutions on Desktop

toolbar powered by Conduit
Caliplus 300x250 NoFlam VitoLiv 468x60 GlucoLo