1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

"'const' qualifiers cannot be applied to 'const MyClass&'"

Discussion in 'C++' started by Smithy S., Aug 31, 2010.

  1. Smithy S.

    Smithy S. New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,

    I have the following purely abstract base class (aka interface):

    Code:
    class IRectangle : public IShape
         {
             public:
                 virtual const ICoordinate3D& const getTopLeft() = 0;
                 virtual const IDimension2D& const getDimension() = 0;
         };
    
    Which depends on the following classes:

    Code:
    class ICoordinate2D
         {
             public:
                 /*----------Public Queries----------*/
                virtual int const getX() = 0;
                virtual int const getY() = 0;
         };
    
    class ICoordinate3D : public ICoordinate2D
         {
             public:
                 /*----------Public Queries----------*/
                virtual int const getZ() = 0;
         };
    
    When trying to compile g++ spits out the following error: "'const' qualifiers cannot be applied to 'const ICoordinate3D&'", with a reference to the line that declares the function getTopLeft(). I absolutely do not get why it's complaining?
     

Share This Page