Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

overloading, overriding, hiding

25 views
Skip to first unread message

sat_...@yahoo.co.uk

unread,
Apr 26, 2008, 6:32:11 PM4/26/08
to
Is this a right classification to explain these method concepts in
this 2x2 matrix?


Same class scope Different
class scopes
Same signature NA
Overriding
Different signature Overloading Hiding

Here, different signatures means functions with same name, but with
different parameter types.

Sat

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

sat_...@yahoo.co.uk

unread,
Apr 28, 2008, 3:58:06 AM4/28/08
to
{ Please don't include parts not necessary to establish context; the
clc++m banner, for example. Please also refrain from top-posting. -mod }

Sorry about the mangled format in my previous post.

Here it goes again.

Is this a right classification to explain these method concepts as
four possible combinations of function siganture and class scope:


same signature & same class scope : Not applicable
same signature & different class scopes : Overriding
different signatures & same class scope : Overloading
different signatures & different class scopes : Hiding

Here, "different signatures" means functions with same name, but with
different parameter types.

Sat

Chris Uzdavinis

unread,
Apr 28, 2008, 10:36:24 PM4/28/08
to
> Is this a right classification to explain these method concepts as
> four possible combinations of function siganture and class scope:
>
> same signature & same class scope : Not applicable

Right.

> same signature & different class scopes : Overriding

This one is more complicated. Since you've demonstrated that making a
table is difficult to format, I'll answer with pseudocode. :)

if (type2 inherits from type1)
{
if (base signature is declared virtual)
{
return DERIVED_OVERRIDES_BASE;
}
else
{
return DERIVED_HIDES_BASE;
}
}
else
{
return COMPLETELY_UNRELATED_FUNCTIONS;
}

> different signatures & same class scope : Overloading

Yes.

> different signatures & different class scopes : Hiding

Yes, but only if there is an inheritance relationship between the
classes.

--
Chris

0 new messages