Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Automatic initialization list in constructor.

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 - Dec 14 2006 : 08:24:26 AM
Preface: While I start implementing the constructor of a class, at the point I typed "Foo::Foo() : " I use to write the initialization list with all superclass constructors and all member variables.

Topic: There should be a suggestion to automatically create the whole initialization list. When I select this suggestion which could be called "Create initialization list" I get e.g. this result:

Header:

class Bar {};
class Foo {
public:
Foo( int apple, int banana );
private:
int m_apple;
int m_banana;
double m_cinnamon;
};


I start at this point (| = cursor):


Foo::Foo( int apple, int banana )
 : | 


The suggestion box appears and I select "Create initialization list". Now I have this situation:


Foo::Foo( int apple, int banana )
 : Bar(), m_apple( apple ), m_banana( banana ), m_cinnamon( 0.0 /* TODO: */ )
{
  |
}


Your objections:
  • Not every initialization is necessary. (I think: you can remove the not necessary member initializations afterwards)
  • Providing a default value while initializing the members is dangerous. (I think: That's true, instead only a comment or other placeholder could written at such places.)

1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Dec 14 2006 : 09:55:16 AM
I like this idea, but I am concerned about some types. For example what about references?

This is actually fairly similar to the idea discussed here:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=5713

and might respond to a very similar solution. The big question is going to be, what to use as the default initialisation value. It is *possible* this could be set via an autotext entry.

On a related front, it is unlikely that VA could reliably match the parameters to the member variables. If people follow a fixed naming convention that we lay down then it could work, but that is never going to happen

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