[ create a new paste ] login | about

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

C++, pasted on Oct 11:
#include <iostream>

class ShapeTwoD
{
public:
    ShapeTwoD() {}
    virtual ~ShapeTwoD() {}

    string getName(){return name;}
    void setName(string const &newName){name = newName;}

    void toString(){}

    virtual double computeArea(){return 2+3.0;}

private:
    string name;
    bool containsWarpSpace;
};

class Square:public ShapeTwoD
{
public:
    virtual double computeArea(){return 2+4.0;}
};

using namespace std;

int main()
{
    Square s;
    s.setName("Sponge");
    cout << s.computeArea() << endl; //outputs 5 when i expect it to output 6
}


Output:
1
6


Create a new paste based on this one


Comments: