views:

60

answers:

1

I've got the following setup. RectangleT class defined in a header file in a library. Attempted to use the class in my main application. When linking I get an error for every function I try to call - except constructor and the GetLeft/GetTop/GetRight/GetBottom - BUT - I do get the error when calling GetWidth / GetHeight.

Here's the code I've got for a simple template class.

namespace My2D
{
    template <typename T>
    class MY2D_API RectangleT
    {
    public:     // Construction
        RectangleT(const T left = 0, const T top = 0, const T right = 0, const T bottom = 0)
            : m_left(left)
            , m_top(top)
            , m_right(right)
            , m_bottom(bottom)
        {
        }

        RectangleT(const RectangleT<T> &source)
            : m_left(source.m_left)
            , m_top(source.m_top)
            , m_right(source.m_right)
            , m_bottom(source.m_bottom)
        {
        }

        virtual ~RectangleT(void)
        {
        }

    public:     // Getters / setters
        T GetLeft() const { return m_left; }
        T GetTop() const { return m_top; }
        T GetRight() const { return m_right; }
        T GetBottom() const { return m_bottom; }
        T GetWidth() const { return m_right - m_left; }
        T GetHeight() const { return m_bottom - m_top; }

        void SetLeft(const T value) { m_left = value; }
        void SetTop(const T value) { m_top = value; }
        void SetRight(const T value) { m_right = value; }
        void SetBottom(const T value) { m_bottom = value; }

    protected:  // Members
        T m_left;
        T m_top;
        T m_right;
        T m_bottom;
    };
}

Anyone got any ideas?!

+2  A: 

I removed compiler directive MY2D_API and tried your code, it works fine, see below.

Windows 7, MS VS 2010

int main ()
{
  My2D::RectangleT < int > rect;

  rect.SetBottom(3);
  rect.SetLeft(3);
  rect.SetRight(8);
  rect.SetTop(8);
  return rect.GetHeight();
}
Gollum