View Single Post
  #7 (permalink)  
Old August 29th, 2008, 05:15 AM
akuatik akuatik is offline
Registered User
Join Date: Aug 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Hi, I'm having overloaded function errors with the example. Could anybody please help me to solve this? I've bold the lines. Thank you

error C2511: 'CLine::CLine' : overloaded member function 'void (const class CPoint &,const class CPoint &,const unsigned long &)' not found in 'CLine'
        d:\programming c++\sketcher\elements.h(30) : see declaration of 'CLine'
// Generic element class
class CElement : public CObject
    // Add virtual function declarations here
    COLORREF m_Color; // Color of an element
    CRect m_EnclosingRect; // Rectangle enclosing an element
    int m_Pen; // Pen width

    virtual ~CElement (){} // Virtual destructor

    // Virtual draw operation
    virtual void Draw(CDC* pDC) const {} // Virtual draw operation
    CRect GetBoundRect() const; // Get the bounding rectangle for an element

    CElement(){} // Default constructor


// Class defining a line object
class CLine : public CElement
    virtual void Draw(CDC* pDC) const; // Function to display a line

    // Constructor for a line object
    CLine(const CPoint& Start, const CPoint& End, const COLORREF Color);
    CPoint m_StartPoint; // Start point of a line
    CPoint m_EndPoint; // End point of a line

    CLine(){} // Default constructor-should not be used


// CLine class constructor
CLine:: CLine(const CPoint& Start, const CPoint& End, const COLORREF& Color)
    m_StartPoint = Start; // Set line start point
    m_EndPoint = End; // Set line end point
    m_Color = Color; // Set line color
    m_Pen = 1; // Set pen width

    // Define the enclosing rectangle
    m_EnclosingRect = CRect(Start,End);

// Draw CLine object
void CLine::Draw(CDC* pDC) const
    // Create a pen for this object and
    // initiliase it to the object color and line width
    CPen aPen;
    if(!aPen.CreatePen(PS_SOLID, m_Pen, m_Color))

        // Pen creation failed. Abort the program
        AfxMessageBox("Pen creation failed drawing a line", MB_OK);

    CPen* pOldPen = pDC->SelectObject(&aPen); // Select the pen

    // Now draw the line

    pDC->SelectObject(pOldPen); // restore the old pen