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!

Class Def's and Declarations question - Visual Studio 6

Status
Not open for further replies.

pghsteelers

Technical User
Apr 21, 2006
121
US
New to C++ I was curious to know why when using Visual Studio 6, and when in the .cpp class definition file, I used the wizard to add a "member function".

This then created in the .h file my skeleton of the definition for this member function declaration. However, my question is, why can I switch from the declaration in the .cpp file to the definition in the .h file using the magic wand, but if I try to switch back to the declaration using the magic wand, it tells me that it is unable to find the declaration for this function.

The thing is that C++ generated the definitions - more so, I thought that maybe I needed to finish putting in the body of the function in the definition, but after doing so, it still didn't make a difference. Below is the declaration and the definition:


Box.h:

CBox operator+(const CBox& aBox) const;

Box.cpp

CBox CBox::eek:perator +(const CBox &aBox) const
{
return CBox(m_Length > aBox.m_Length? m_Length:aBox.m_Length,
m_Breadth > aBox.m_Breadth? m_Length:aBox.m_Breadth,
m_Height + aBox.m_Height);
}



Any answer to why?
 
This then created in the .h file my skeleton of the definition for this member function declaration.

There are declarations in .h file. Function definition (usually in .cpp) == function header + function body.

Class wizard creates .h and .cpp files for every new class then switches between its declaration (in .h) and definitition (in .cpp) w/o any problems on my VS 6.0 installation.

Don't suppress browse info generation in your project debug configuration.
 
I never use the "magic wand", so I can't really say as to what it does or why, but if it appears to be broken, make sure you have the latest VC++ 6.0 Service Pack installed.

If that doesn't work, I wouldn't worry about it. It's just one of the many useless toys that Microsoft put in Visual Studio that aren't really worth the screen space they take up.
If you switch from Class View to File View, you can just double-click on the .h or .cpp file that you want...
 
Thanks for the input everyone. Switching using the file view was the way I had to do it after all since it was only working one direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top