Topic: virtual and static method with same name
Author: jr@efi.sintef.no (Jarand Roeynstrand)
Date: 2 Feb 1995 22:07:44 GMT Raw View
In article <3grcvf$epv@news.uni-c.dk>, mojemj@unidhp.uni-c.dk (Mogens Jensen) writes:
[Stuff about Passing char ** as const char ** beeing illegal deleted]
|>
|> I agree that it is a strange restriction, why does it indicate a logic
|> error?, and what is the difference between [char*->const char*] and
|> [char**->const char**]?
|>
|> One could imagine that const meant anti-volatile, so that the compiler
|> was able to make certain presumptions (only load once); and a non-const
|> pointer could possibly violate this assumption - but this can't be the
|> case as [char*->const char*] is allowed (and we have the volatile
|> keyword) ...
|>
Consider this example, that is legal if the conversion [char**->const char**]
is legal:
void f( const char ** p)
{
static const char *message= "Hello world!";
*p = message;
}
main()
{
char *p;
f( &p );
p[0] = 'F'; // Breaks constness of f::message
}
Hope this helps.
--
==== Best regards
\\ Jarand Roeynstrand
\\ DIG-hackers department
\====\
.,;,\ \ EFI
,;;;;;;;;,_/ ____ N-7034 Trondheim
| | Norway
| |
\__/
Phone: +47-73 59 72 75 Email: jr@efi.sintef.no
Author: jason@cygnus.com (Jason Merrill)
Date: Wed, 18 Jan 1995 08:26:36 GMT Raw View
>>>>> Timo Kettunen <timo.kettunen@pragma.pp.fi> writes:
> Sometimes it is desirable to have same method name for static and virtual
> function. With different parameter lists this succeeds, but parameterless
> methods are trickier.
> One way to circumvent this problem is using default parameter for the
> static one.
> Does this conform to standard?
No, the call a.f() is ambiguous. Use different names.
Jason