[ create a new paste ] login | about

Link: http://codepad.org/dpX39xgZ    [ raw code | output | fork ]

C++, pasted on Dec 14:
#include <iostream>
using namespace std;

class Subjects {
    void learnToCode() {cout << "Subjects : Learn to Code" << endl;};
    void sitForExam() {cout << "Subjects : Sit for Exam" << endl;};
};

class Physics : public Subjects {
    void sitForExam() {cout << "Physics: Sit for Exam" << endl;};
    void learnRProgram() {cout << "Physics : Learn R Programming" << endl;};   
};

class BigData : public Physics {
    void learnToCode() {cout << "BigData : Learn to Code" << endl;};
    void learnRProgram() {cout << "BigData : Learn R Programming" << endl;};
};

class CloudComputing : public Subjects {
    void learnToCode() { cout << "CloudComputing : Learn to Code" << endl;};
    void sitForExam() { cout << "CloudComputing : Sit for Exam" << endl;};
};

int main() {
    Physics *pilot = new Physics;
    BigData *Ben = new BigData;
    CloudComputing *Clara = new CloudComputing;

    Ben.sitForExam();       /* Physics: Sit for Exam */
    Clara.learnToCode();    /* CloudComputing : Learn to Code */
    pilot.sitForExam();     /* Physics: Sit for Exam */
    Ben.learnToCode();      /* BigData : Learn to Code */
    Clara.learnRProgram();  /* Doesn't compile */
    pilot.learnRProgram();  /* Physics : Learn R Programming */

    return 1;
}


Output:
1
2
3
In function 'int main()':
Line 29: error: request for member 'sitForExam' in 'Ben', which is of non-class type 'BigData*'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: