Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1530: rename of members

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
diavo Posted - Jul 19 2006 : 03:18:57 AM
given the following example:

class Test
{
	Test(int member1) : member(member1) {};
	int	member;
};


class Test
{
	Test(int member) : member(member) {};
	int	member;
};

If you try to rename the member variable of the first example, all works fine.
If you try to rename the member variable of the second example, the member variable in the init list of the constructor
will not be renamed.
I know, that's maby dirty code, but it is valid c++ code, too. And so it should work.
8   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Jul 22 2006 : 12:47:05 PM
*ah* now i see what you are getting at, and i am still feeling quite "upset". my initial reaction was "that will never compile" but i can see how the compiler can manage to resolve this.

i can see why people are tempted to do just this, so i have put in a case for this one.

case=1767
diavo Posted - Jul 21 2006 : 06:14:42 AM
or better:


class Test
{
Test(int member1) : member(member1) {};
	int	member;
};



class Test1
{
	Test1(int member) : member(member) {};
	int	member;
};
diavo Posted - Jul 21 2006 : 06:12:32 AM
Oh, I think you understand me wrong. The two classes are not in the same code. The two class are two !separat! examples.
My problem was the renaming of the member variable in the initializing list in the constructor.
To avoid misunderstandings here a different code again:


class Test
{
Test(int member1) : member(member1) {};
	int	member;
};



class Test1
{
	Test1(int member) : member(member) {};
	int	member;
};


If you try to rename the member variable of the first example, all works fine.
If you try to rename the member variable of the second example, the member variable in the init list of the constructor
will not be renamed.
jpizzi Posted - Jul 21 2006 : 01:31:14 AM
I placed the code into a project in VS 2005. It does work. I examined the assembly and watched the values in the debugger.

Still, I would not do this in my code. I would try to educate anyone that worked for me that did this once. I would fire anyone that worked for me that did this more than once.
feline Posted - Jul 20 2006 : 6:19:37 PM
i am SO tempted to reply "but if it compiles then it must be perfect code", but i shall try to resist.

a related bug, to do with duplicate names in different classes is listed as fixed in the next build, so that may help with this.

i do have to agree with bugfix, this is a terrible idea. how can you use one of the classes? or more accurately, if you do create an instance of the class, which one was it?
bugfix Posted - Jul 20 2006 : 05:07:57 AM
Heh, and b/c MS has zillion of bugs in their stuff you want them too?
Beside those are examples not realworld code, no copy&paste w/o thinking code.
... and I've always thought error propagation is a numeric problem only:)
diavo Posted - Jul 20 2006 : 01:57:25 AM
Yes sure, but for example, Microsoft use this in many examples in their MSDN.
bugfix Posted - Jul 19 2006 : 12:08:43 PM
quote:
Originally posted by diavo
I know, that's maby dirty code, but it is valid c++ code, too. And so it should work.


Not only maybe it definitely is bad style and prone for bugs/sideeffects.

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