Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1532: Subclasses w/o impl in .h, not parsed/displ.

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
drzoom Posted - Aug 24 2006 : 07:42:56 AM

Subclassses with a forward declaration in the header file are not parsed/displayed with VA.

Examplecode:

Foo.h:

#pragma once

namespace x {
namespace y {

class Bar {};

class Foo
{
	class Private;

public:
	Foo();
	~Foo();

public:
	Bar getBar() const;

private:
	Private* m_p;
};

}
}


Foo.cpp:

#include "Foo.h"

namespace x {
namespace y {

class Foo::Private
{
public:
	Bar bar;
};

Foo::Foo() 
{
	m_p = new Private();
}

Foo::~Foo() 
{

}

Bar Foo::getBar() const
{
	return m_p->bar
}


}
}


If you change:


class Private;


...into...


class Private {};


The class is displayed in the class browser. With only as forward declaration, the class is not displayed. But the cpp file is parsed. I created a class X in the cpp file in the x::y namespace, and this class was displayed in the class browser too.

best regards
Tobias

3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 27 2006 : 2:10:02 PM
*ah* that makes a lot of sense.

placing this code into a C++ project in VS2003 with VA 1533 i saw the same thing, but after restarting the IDE the HCB (the bottom part of VA View) is showing me this when i hover the mouse over "namespace y"



do you see the same thing after restarting the IDE, or something different? this suggests there is simply some delay in VA reparsing the code and updating the display.


as an aside do you mean Qt from Trolltech? I use Qt 3.3.3 a lot, but never tend to read the actual Qt source code, so i was not aware of this. do you have any examples off the top of your head?
drzoom Posted - Aug 27 2006 : 06:09:37 AM
If you create classes which are exported for a DLL, and you need keeping compatiblity between different version, the interface must not change.

With a such private class, implemented in the implementation, the attributes or private methods are hidden from the interface.

It's possible, declaring a such class in a separate, not exported, header file. But it's easier to do it that way.

See the Qt implementation for many examples of this technique.

feline Posted - Aug 26 2006 : 3:31:40 PM
it makes sense to me that the HCB is not showing the class. it looks like the HCB is reading the class definition from the header, which is where it is defined.

what i am not sure about is why you would do something like this. i understand forward declairing a class, i do that all of the time myself, but why define the sub class in the cpp file?

when ever i use a sub class i always define it in the header.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000