Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class Identifiers Never Work? [closed]

I'm making a RoomDimension class that uses a FeetInches class, but whenever I use FeetInches inside of RoomDimension, I get an avalanche of error messages, including:

error C2146: syntax error : missing ';' before identifier 'length'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Here are the classes:

class FeetInches
{
private:
   int feet;        // To hold a number of feet
   int inches;      // To hold a number of inches

public:
   // Constructor
    FeetInches(int f = 0, int i = 0)
        { feet = f;
          inches = i; }

   // Mutator functions
    void setFeet(int f)
        { feet = f; }

    void setInches(int i)
        { inches = i; }

   // Accessor functions
    int getFeet() const
        { return feet; }

    int getInches() const
        { return inches; }

};

class RoomDimension
{
private:

    FeetInches length;
    FeetInches width;

public:

    // constructors
    RoomDimension(void);

    // getter functions
    FeetInches getLength(void) const
    { return length; }

    FeetInches getWidth(void) const
    { return width; }

    // setter functions
    void setLength(FeetInches l)
    { length = l; }

    void setWidth(FeetInches w)
    { width = w; }

};

What am I doing wrong?

like image 945
SoloMael Avatar asked Jul 10 '26 18:07

SoloMael


1 Answers

I didn't see any problem except that the constructor of RoomDimension is not implemented.

like image 53
Eric Z Avatar answered Jul 13 '26 12:07

Eric Z