Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>;
- using namespace std;
- class Student {
- protected:
- char name[21];
- char ssn[10];
- float gpa;
- int credits;
- public:
- Student::Student() {};
- Student(const char n[], const char ss[], float& gp, int& cred) {
- name[21] = n[21];
- ssn[10] = ss[10];
- gpa = gp;
- credits = cred;
- }
- virtual void print() {
- cout << "Name: " << name << endl;
- cout << "SSN: " << ssn << endl;
- cout << "GPA: " << gpa << endl;
- cout << "Credits: " << credits << endl;
- }
- virtual float tuition() const = 0;
- };
- class undergrad : public Student {
- protected:
- float undergrad_rate;
- char* year;
- public:
- undergrad::undergrad() {}
- undergrad(float ugr, char* yr, const char n[], const char ss[], float&
- gp, int& cred) :
- Student(n, ss, gp, cred), undergrad_rate(ugr), year(yr){}
- void set_year(char* yr) {
- year = yr;
- }
- char* getYear() {
- return year;
- }
- float getRate() {
- return undergrad_rate;
- }
- void print() {
- Student::print();
- cout << "Undergrad rate: " << undergrad_rate << endl;
- cout << "year: " << year << endl;
- }
- float tuition() {
- //cout << "The tuition is $35000" << endl;
- return 35000;
- }
- };
- class grad : public Student {
- protected:
- float grad_rate;
- char* thesis;
- public:
- int main(){
- char* jr = "Junior";
- char* sr1 = "Senior";
- char* fr = "Freshman";
- char* sr = "Sophmore";
- undergrad g(380, jr, "M", "000111222", 4.0, 12);
- g.print();
- system("pause");
- return 0;
Add Comment
Please, Sign In to add comment