A
Aguilar, James
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
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