Shadowing a parameter

From: Aguilar, James (jfa1_at_cec.NOBOTSwustl.edu)
Date: 08/08/04


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



Relevant Pages

  • Re: Another try at Pythons selfishness
    ... newbie-friendly: ... If I declare a member ... Python (I made attempts with C++ that were moderately ... By contrast, Javascript seems positively obtuse. ...
    (comp.lang.python)
  • Re: security issues with forth
    ... the multiuser course I first posted about other class members were inconvenienced). ... No one really suffers, no damage is done, but one's attention is rivited and the inconvenience is sufficient to motivate the student to avoid it. ... It's not easy and painless to ignore like an error message. ... Nor can the newbie simply turn off error messages, since the compiler *still* won't generate anything that executes. ...
    (comp.lang.forth)
  • Re: Swapping Bullshit
    ... >>a newbie be confused by the simplest thing about pointers in C? ... If it's not a proper identifier, you cannot declare it. ... >>When replying to a newbie question, ... >additional remarks about terminology (or other theoretical concepts, ...
    (comp.lang.c)
  • Re: How to Define a global const class variable in MFC?
    ... but in vc++ it seems that we have to both declare and define variables in ... would declare an array of fixed size in C++ escapes me...). ... I can write the whole header files and source files but I thought it will be ... declarations are so we can figure out why the error message, that SPECIFIC error message, ...
    (microsoft.public.vc.mfc)
  • Re: Matching subsets of two strings
    ... >>> ot quite sure what values it puts in what arrays, ... > read I noticed the bit about intersection (and then it struck ... > declare one of the variables - do I have to declare ... The actual error message should tell you what is wrong. ...
    (comp.lang.perl.misc)