You are here:

C++/term does not evaluate to a function

Advertisement


Question
There is a  error in this code but I couldn't understand what is the problem.:

CDC* pDC;
CPen    pen( PS_DOT, 1, RGB(0,255,0) );
CPen *pOldPen = pDC->SelectObject(&pen);          
CRect rect;
rect(&pen,(float)-m_Objects[i].m_width/2,-m_Objects[i].m_height/2,m_Objects[i].m_width,m_Objects[i].m_height);   
pDC->Ellipse( rect );

error C2064: term does not evaluate to a function
rect(&pen,(float)-m_Objects[i].m_width/2,-m_Objects[i].m_height/2,m_Objects[i].m_width,m_Objects[i].m_height);   
in this line.

Could u please help me for slow that problem. (I need to draw dotted line rectangle) use visual c++6 and GDI.


Answer
sam, Thank you for your question.

The problem is in your statement

rect(&pen,
(float)-m_Objects[i].m_width/2,
-m_Objects[i].m_height/2,
m_Objects[i].m_width,
m_Objects[i].m_height);


Variable 'rect' is a class instance. You are using it as a function call. If you want to set 'rect' to a value, you should use code like this:

rect.SetRect(...);

Another error, a minor one, is that you are converting the first argument to 'float'. This is probably not what you intended to do. SetRect requires 'int' arguments.

David Spector

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Spector

Expertise

Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.

Experience

I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Publications
Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

Education/Credentials
ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 About.com. All rights reserved.