Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 1532: Subclasses w/o impl in .h, not parsed/displ.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

drzoom
Ketchup Master

Switzerland
57 Posts

Posted - Aug 24 2006 :  07:42:56 AM  Show Profile  Reply with Quote

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


best regards
Tobias

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Aug 26 2006 :  3:31:40 PM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

drzoom
Ketchup Master

Switzerland
57 Posts

Posted - Aug 27 2006 :  06:09:37 AM  Show Profile  Reply with Quote
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.


best regards
Tobias
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Aug 27 2006 :  2:10:02 PM  Show Profile  Reply with Quote
*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?

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000