Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Document/View and accessor functions

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi! I'm trying to write an MFC exercise program where a circle is drawn wherever the user clicks in the main frame. I've learned that the document/view way to do this is to store the circle's location in the document, and update it from the view. The problem is when I add private member variables and an accessor function to the CMyAppDoc class, I keep getting a "undeclared identifier" compiler error wherever I reference the members in the function. Here's the relavent parts of my code:
-------------------------------------
// MyAppDoc.h
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDrawDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CDrawDoc();
// My additions are next 3 lines
int m_iCurrX;
int m_iCurrY;
void SetPoint(CPoint point);
// ClassWizard stuff


// MyApp.cpp
// ClassWizard stuff
void SetPoint(CPoint point){
// Undeclared Identifier on next 2 lines
m_iCurrPosX = point.x;
m_iCurrPosY = point.y;
}
----------------------------
I've played around with public, private, and protected variable scopes of different data types with no change, and when I set this same thing up in CMyAppView instead it works fine.

Thanks for any ideas, this is frustrating...

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
I just noticed that the example above declares m_iCurrX and m_iCurrY, and tries to use m_iCurrPosX and m_iCurrPosY. This is the result of trying different possibilities before posting my code here, and is not the cause of the problem. Is there some trick to adding members to the document that I may not know about? The ClassWizard disables the Add Member button when CMyAppDoc is selected, could this be part of my problem?

Thank you!

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top