User forums > Nightly builds
The 23 august 2006 build is out.
mdelfede:
--- Quote from: MortenMacFly on August 24, 2006, 10:56:13 am ---
--- Quote from: Outis on August 24, 2006, 10:41:08 am ---And code-completion doesn't work if there's a this pointer in front of a variable (this->foobar).
--- End quote ---
A bit of topic, but anyway: I never understood why it makes sense to add the this pointer in front. The only reason I see is if one has a local variable with the same name. But this would IMHO be a bad design. Maybe someone can enlighten me?!
--- End quote ---
In template code I found that 'this' is required, if not gcc gives an error. Don't know why.
Bad one :
--- Code: ---template<class BClass, class ImplClass> class DerClass : public BClass
{
public:
DerClass() : BClass() { impl = new ImplClass();} <--- ERROR, 'impl' NOT FOUND
ImplClass *getImpl() { return dynamic_cast<ImplClass *>(this->impl);}
};
--- End code ---
Good one :
--- Code: ---template<class BClass, class ImplClass> class DerClass : public BClass
{
public:
DerClass() : BClass() { this->impl = new ImplClass();}
ImplClass *getImpl() { return dynamic_cast<ImplClass *>(this->impl);}
};
--- End code ---
And somebody uses it in constructors too...
--- Code: ---X:X(int a, b, c)
{
this->a = a;
this->b = b;
.....
--- End code ---
I find that one awful, but...
Ciao
Max
marfig:
OT: The compiler doesn't look for base classes unqualified identifiers that are depending on a template parameter. So this-> becomes a necessity under those situations. The problem is that if you don't, then errors could only be caught after the template was instantiated. By using this-> you can give the compiler the opportunity to catch errors much sooner, during the parsing phase.
There is also of course always the problem of code readability. With the right conditions in complexity, it is quiet possible the use of this-> will make the code more readable even without templates.
Pecan:
--- Quote from: MortenMacFly on August 24, 2006, 10:56:13 am ---
--- Quote from: Outis on August 24, 2006, 10:41:08 am ---And code-completion doesn't work if there's a this pointer in front of a variable (this->foobar).
--- End quote ---
A bit of topic, but anyway: I never understood why it makes sense to add the this pointer in front. The only reason I see is if one has a local variable with the same name. But this would IMHO be a bad design. Maybe someone can enlighten me?!
--- End quote ---
Meyers has an example in the first book of the set showing a necessary use of "this" in multiple inheritance.
MoonKid:
Another thing about the virtual folders.
It is not possible to drag&drop virtual folders. For example I want to drag an existing folder as a sub-folder to another one.
mandrav:
--- Quote from: MoonKid on August 24, 2006, 07:17:56 pm ---Another thing about the virtual folders.
It is not possible to drag&drop virtual folders. For example I want to drag an existing folder as a sub-folder to another one.
--- End quote ---
Not implemented yet.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version