Post #264,983
8/15/06 5:49:16 PM
|

The easiness to keep track of is not the issue
The issue is your assertion that behavior of the function changes based on the const-ness of the object, which is just plain not true.
jb4 "So don't pay attention to the approval ratings that say 68% of Americans disapprove of the job this man is doing. I ask you this, does that not also logically mean that 68% approve of the job he's not doing? Think about it. I haven't." — Stephen Colbert, at the White House Correspondent's Dinner 29Apr06
|
Post #264,989
8/15/06 6:51:19 PM
|

Huh?
You get a different implementation of the method depending on whether the reference to the object is const or not const. So the "apparent behavior" of the function changes.
That's all I'm saying.
[link|http://www.blackbagops.net|Black Bag Operations Log]
[link|http://www.objectiveclips.com|Artificial Intelligence]
[link|http://www.badpage.info/seaside/html|Scrutinizer]
|
Post #265,048
8/16/06 10:12:37 AM
|

No...
You get the implementation you specify. Every time. No exceptions. That implementation does not change because the object is const or not. The code is the code, and it doesn't magically change because you invoked one overload vs. another.
jb4 "So don't pay attention to the approval ratings that say 68% of Americans disapprove of the job this man is doing. I ask you this, does that not also logically mean that 68% approve of the job he's not doing? Think about it. I haven't." — Stephen Colbert, at the White House Correspondent's Dinner 29Apr06
|
Post #265,054
8/16/06 11:11:53 AM
|

I think you're talking past each other...
Because to me it looks like you're both saying the same thing.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #265,060
8/16/06 11:48:14 AM
|

And you specify that by....
the type of the reference to the object. Which can change. Which kind of makes it the anti-polymorphism.
But I think Scott is right. 'nuff said.
[link|http://www.blackbagops.net|Black Bag Operations Log]
[link|http://www.objectiveclips.com|Artificial Intelligence]
[link|http://www.badpage.info/seaside/html|Scrutinizer]
|
Post #265,069
8/16/06 12:32:21 PM
|

We'll leave it at that.
But it's important to be clear (and not sarcastic) when trying to inform a newbie. YMMV....
jb4 "So don't pay attention to the approval ratings that say 68% of Americans disapprove of the job this man is doing. I ask you this, does that not also logically mean that 68% approve of the job he's not doing? Think about it. I haven't." — Stephen Colbert, at the White House Correspondent's Dinner 29Apr06
|
Post #265,080
8/16/06 1:27:58 PM
|

I wasn't trying to be sarcastic
But I know of no allegedly OO language where the method implementation lookup depends on the type of the reference you hold. It runs counter to how polymorphism is supposed to work in which the object responds based on the type of the object and not the type of the reference. So in that respect, C++ is just weird in OO world (and thus, counterintuitive).
Gotta warn the newbies.
[link|http://www.blackbagops.net|Black Bag Operations Log]
[link|http://www.objectiveclips.com|Artificial Intelligence]
[link|http://www.badpage.info/seaside/html|Scrutinizer]
|
Post #265,081
8/16/06 1:35:32 PM
|

No need to specify OO in this case
So in that respect, C++ is just weird in OO world (and thus, counterintuitive). That sentence stands on it's own with 'in OO world' removed. Jay
|
Post #265,090
8/16/06 3:06:42 PM
|

What does the type of the reference have to do with anything
The type of reference to the object is effectively the type of the object. There is no difference between having a const reference to an object in C++ and having a const object.
jb4 "So don't pay attention to the approval ratings that say 68% of Americans disapprove of the job this man is doing. I ask you this, does that not also logically mean that 68% approve of the job he's not doing? Think about it. I haven't." — Stephen Colbert, at the White House Correspondent's Dinner 29Apr06
|