Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.
Закрыть

overloading, overriding, hiding

23 просмотра
Перейти к первому непрочитанному сообщению

sat_...@yahoo.co.uk

не прочитано,
26 апр. 2008 г., 18:32:1126.04.2008
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

не прочитано,
28 апр. 2008 г., 03:58:0628.04.2008
{ 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

не прочитано,
28 апр. 2008 г., 22:36:2428.04.2008
> 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 новых сообщений