Re: Suggestion
From: Alf P. Steinbach (alfps_at_start.no)
Date: 09/07/04
- Next message: Mike Wahler: "Re: The getline function"
- Previous message: David Hilsee: "Re: Why "this" is a pointer, I just realized!"
- In reply to: Eivind Grimsby Haarr: "Suggestion"
- Next in thread: Aguilar, James: "Re: Suggestion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 07 Sep 2004 03:26:32 GMT
* Eivind Grimsby Haarr:
>
> When using polymorphism in a big system, I have sometimes come across
> problems when changing the signature of the function in the base class,
> and forgetting to change the signature of the derived functions
> accordingly. (Most often when only some of the derived classes redefine
> it.) Accessing the objects with base class pointers, the version in the
> base class is called, which is not what I wanted. This is most often very
> difficult to detect.
>
> This has made me come up with an idea for a compiler/language feature that
> would fix this problem: A keyword in front of the derived function that
> says that this function is derived from a base class, and the compiler
> should issue an error if a function with a similar signature doesn't
> exist in one of the base classes.
>
> What do you think about this idea? Is it just too much pain for a rare
> problem?
It's always a good idea to catch errors at the earliest time possible,
preferably analysis and design, but if not, then compile-time.
Your idea is a Good One (TM) and is implemented in .NET languages such as
VB.NET and C#, in the latter using the keywords "override" (override) and
"new" (shadow).
Getting it into C++, that's another matter... ;-)
-- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
- Next message: Mike Wahler: "Re: The getline function"
- Previous message: David Hilsee: "Re: Why "this" is a pointer, I just realized!"
- In reply to: Eivind Grimsby Haarr: "Suggestion"
- Next in thread: Aguilar, James: "Re: Suggestion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|