Shadowing a parameter
From: Aguilar, James (jfa1_at_cec.NOBOTSwustl.edu)
Date: 08/08/04
- Next message: Pete Becker: "Re: Constness Complications"
- Previous message: AlesD: "Re: Constness Complications"
- Next in thread: Rob Williscroft: "Re: Shadowing a parameter"
- Reply: Rob Williscroft: "Re: Shadowing a parameter"
- Reply: Rolf Magnus: "Re: Shadowing a parameter"
- Reply: Peter Ammon: "Re: Shadowing a parameter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 8 Aug 2004 16:52:04 -0400
Hey all. I was making a newbie mistake that I eventually figured out. That
is not my question. My question is about the error message. So let me set
the stage for you:
class Superclass
{
public:
Superclass(int);
}
class Subclass : public Superclass
{
public:
Subclass(int);
}
As you all surely know, the way to declare the constructor of subclass so
that it uses that of superclass is
Subclass::Subclass(int x)
: Superclass(x)
{ . . . }
As a newbie who comes from a Java background, I somehow managed to miss this
colon initializer notation in my text (B.Stoustrup or however you spell it).
So I was writing it as any Java newbie would:
Subclass::Subclass(int x)
{ Superclass::Superclass(x); . . . }
The real question, though, is why the heck can't the error message be more
useful:
"Error: declaration of x shadows parameter"
What in the world does that mean? What is "shadowing" a parameter. And
where do I declare something that does so? As far as I can see, the
parameter itself is the only declaration of any kind. This is from g++ for
Cygwin, whatever the most recent version is.
Yours,
James
- Next message: Pete Becker: "Re: Constness Complications"
- Previous message: AlesD: "Re: Constness Complications"
- Next in thread: Rob Williscroft: "Re: Shadowing a parameter"
- Reply: Rob Williscroft: "Re: Shadowing a parameter"
- Reply: Rolf Magnus: "Re: Shadowing a parameter"
- Reply: Peter Ammon: "Re: Shadowing a parameter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|