Solution

Sponsored Links



Code:
#include <iostream>
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=2.3;
}


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: "<<name<<endl;
cout<<"Roll number: "<<rollNumber<<endl;
cout<<"Semester: "<<semester<<endl;
cout<<"Current GPA: "<<cgpa<<endl;
} 
};

int main()
{Student a;
Student b("name",2345,"Spring 2010",3.5);
a.print();
b.print();
system("pause");
return 0;
}