|
Boost : |
From: Christopher Woods (cwoods_eol_at_[hidden])
Date: 2007-05-29 12:49:44
Costin Calisov wrote:
> Ok, good to know that, but, I'm still curious what is wrong with my code.
> Why is it passing a compiler and why is failing on the other?
>
Probably just a choice of internal compiler design...
The following appears to work on MSVC:
class final_base
{
protected:
final_base();
};
class final : public virtual final_base
{
protected:
final();
private:
final(const final&);
};
Notice that I used protected construction and specified a private copy
constructor for final.
The latter gets around's MSVC error re: no copy constructor or explicit
copy constructor. It seems that MSVC compiler is implicitly defining an
explicit copy constructor so you have to declare one to get around it.
The former lets you use final without having to remember to inherit from
it protected/private:
class B : final
{
public:
B() {}
};
class C : B
{
public:
C() {} // Error - no derive from the B but msg is not obvious IMHO
};
int main()
{
B t1;
B t2(t1); // Okay - because of private copy constructor in final
}
HTH,
-Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk