How to get doc pointer in a view

In CView derived class i need to get a pointer to the associated document. How to do it?
jmartins71Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Answers2000Connect With a Mentor Commented:
The answer is that the cast is correct, but the code is wrong, change to

CSpyLoaderDoc* GetDocument() {return (CSpyLoaderDoc*)m_pDocument; }


The reason you get a stack overflow is there is infinite recursion in your code, GetDocument calls itself add infinitum (filling the stack till your program crashes)

0
 
BridgeCommented:
GetDocument()
0
 
jmartins71Author Commented:
Thanks Bridge but i need more information.

My cview derived class is CSpyLoaderView
My cdocument derived class is CSpyLoaderDoc

in CSpyLoaderView i have the following inline function

CSpyLoaderDoc* GetDocument() {return (CSpyLoaderDoc*)GetDocument();}

When i call GetDocument i trigger a stack overflow exception.
Is the casting incorrect?
Can you give me a line.
0
 
jmartins71Author Commented:
Thanks Answer2000
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.