Class errors

Hi guys. Im getting started with my program and am getting error on my set up of the classes. Not sure why i think im doing them right. line 13, 17, 21 say control reaches end of non void function. line 27, 43 says base class polygon has a flexible array member.
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class polygon
{
public:
    polygon(int numSides = 0);//+ Polyon(numSides:int) default is 0
    //{+ set(sideNum: int, value:int) : void, ensures no negative side values
    void set(){
        int sideNum =0;
        int value=0;
    }
    //+ get (sideNum:int):int, returns the value of sides[sideNum]
    int get(int sideNum){
        
    }
    //+ perimeter(): int virtual returns the perimeter of the polygon
    int virtual perimeter(){
        
    }
    //+ area(): double virtual, returns the area of the polygon
    double virtual area(){
        
    }
private:
    int numOfSides();
    int side[];// listed in clockwise order , MAX sides is 100
};

class Rectangle : public polygon
{
public:
    Rectangle();//class polygon(4)
    double virtual area();//appropriatley... from polygon class
    int perimeter();// appropriatley.... from polygon class
};

class Square : public Rectangle
{
public:
    Square();//appropriately
    double virtual area();//appropriately
    int virtual perimeter();//appropriately
};
    
class RightTri : public polygon
{
public:
    RightTri();//class polygon(3)
    double virtual area(); // appropriately
    int virtual perimeter();// appropriately
};
    
class RectSolid : public Rectangle
{
public:
    int volume();//return the volume... may not be int
private:
    int height;
};
closed account (SECMoG1T)
13, 17, 21 are supposed to be returning a value
Any idea about 27, 43?
closed account (SECMoG1T)
I am no sure but I doubt your line 24; from my knowledge static array size shouldn't change and should be provided on intialization but then again there are a number of more friendly options available

1. Switch to vectors
2. Use dynamic arrays
Line 24: This is a zero sized array. Not allowed.

Topic archived. No new replies allowed.