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
 1530: rename of members
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

diavo
Senior Member

Germany
31 Posts

Posted - Jul 19 2006 :  03:18:57 AM  Show Profile  Reply with Quote
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.

bugfix
Tomato Guru

Germany
324 Posts

Posted - Jul 19 2006 :  12:08:43 PM  Show Profile  Reply with Quote
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.

http://www.mf-sd.de
Go to Top of Page

diavo
Senior Member

Germany
31 Posts

Posted - Jul 20 2006 :  01:57:25 AM  Show Profile  Reply with Quote
Yes sure, but for example, Microsoft use this in many examples in their MSDN.
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Jul 20 2006 :  05:07:57 AM  Show Profile  Reply with Quote
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:)

http://www.mf-sd.de
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jul 20 2006 :  6:19:37 PM  Show Profile  Reply with Quote
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?

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

jpizzi
Tomato Guru

USA
642 Posts

Posted - Jul 21 2006 :  01:31:14 AM  Show Profile  Reply with Quote
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.

Joe Pizzi
Go to Top of Page

diavo
Senior Member

Germany
31 Posts

Posted - Jul 21 2006 :  06:12:32 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

diavo
Senior Member

Germany
31 Posts

Posted - Jul 21 2006 :  06:14:42 AM  Show Profile  Reply with Quote
or better:


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



class Test1
{
	Test1(int member) : member(member) {};
	int	member;
};
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jul 22 2006 :  12:47:05 PM  Show Profile  Reply with Quote
*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

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