Why isn't the getlength function working?

How can I make the getLength function work please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>

class Shape
{
public:
Shape(){}
virtual ~Shape(){}
};

class Rectangle : public Shape
{
public:
Rectangle(int length=5, int width):Shape(){}
~Rectangle(){}
int getLength(){return length;}
protected:
int length, width;
};

class Square : public Rectangle
{
public:
Square(int length):Rectangle(length,length){}
virtual Square(const Square & other):Rectangle(other.length, other.length){}
~Square(){}
};

int main()
{
Square Object();
std::cout << "The length is << " <<Object.getLength()<<std::endl;
}
Stop asking the same questions over and over, Alistair. Read the answers people have already posted. This question already has an answer on a previous thread.
Last edited on
Topic archived. No new replies allowed.