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
 Feature Requests
 Automatic initialization list in constructor.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

drzoom
Ketchup Master

Switzerland
57 Posts

Posted - Dec 14 2006 :  08:24:26 AM  Show Profile  Reply with Quote
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.)


best regards
Tobias

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Dec 14 2006 :  09:55:16 AM  Show Profile  Reply with Quote
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

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