why is the second constructor shadowing the first?
class RC2{
private;
bool keyset;
public:
RC2(uint32_t t1 = 64){
keyset = false;
}
RC2(const std::string KEY, uint32_t t1 = 64){
RC2(t1);
//setkey(KEY);
}
};
is giving me:
error: declaration of 'RC2 t1' shadows a parameter
i would think that there is no way for the compiler to mess up distinguishing between these
im using codeblocks gcc with C++0x
Because
RC2(t1);is a local variable declaration shadowing argumentt1, not a call to the other constructor. The following code is also valid:Note! Before C++11, there was no way to call another constructor on the same class from an constructor in C++. If you are using an old C++ version make an
Init()-method which both constructors invoke.