D
developereo
Hi folks,
Can somebody shed some light on this problem?
class Interface {
protected:
Interface() { ...}
virtual ~Interface() { ... }
public:
virtual method() = 0;
}
class Impl1: public Interface {
public:
Impl() { ... }
Impl(const Interface&); // problem 1
virtual ~Impl() { ... }
Impl& operator=(const Interface&); // problem 2
virtual method() { ... }
}
The problem is that the compiler (VC 2005) insists on generating
Impl1(const Impl1&) // copy constructor
and
Impl& operator=(const Impl1&) // default assignment operator
The problem is I do not want these methods.
I want Impl1 to be able to construct/assign itself from any (other)
Impl
satisfying the Interface. That's the whole point of having an
Interface.
Why can't the compiler use my supplied methods, since every Impl1 can
be implicitly cast down to an Interface anyway?
Thanks,
J.
Can somebody shed some light on this problem?
class Interface {
protected:
Interface() { ...}
virtual ~Interface() { ... }
public:
virtual method() = 0;
}
class Impl1: public Interface {
public:
Impl() { ... }
Impl(const Interface&); // problem 1
virtual ~Impl() { ... }
Impl& operator=(const Interface&); // problem 2
virtual method() { ... }
}
The problem is that the compiler (VC 2005) insists on generating
Impl1(const Impl1&) // copy constructor
and
Impl& operator=(const Impl1&) // default assignment operator
The problem is I do not want these methods.
I want Impl1 to be able to construct/assign itself from any (other)
Impl
satisfying the Interface. That's the whole point of having an
Interface.
Why can't the compiler use my supplied methods, since every Impl1 can
be implicitly cast down to an Interface anyway?
Thanks,
J.