H
Hendrik Schober
Hi,
consider this:
#include <iostream>
struct Base {
Base() {std::cout << "Base\n";}
Base(Base&) {std::cout << "Base(Base&)\n";}
};
template< typename T >
struct TBase : Base {
TBase() : Base() {};
TBase(Base& obj) : Base(obj) {std::cout << "TBase(Base&)\n";}
};
struct Derived : TBase<int> {
Derived() : TBase<int>() {std::cout << "Derived()\n";}
Derived(Derived& obj) : TBase<int>(obj) {std::cout << "Derived(Derived&)\n";}
};
int main()
{
Derived d1;
Derived d2(d1);
return 0;
}
(Of course, this doesn' make sense. The real code
is a lot more complicated.)
Using VC7.1 this outputs
Base
TBase()
Derived()
Base(Base&)
Derived(Derived&)
whereas I would have expected
Base
TBase()
Derived()
Base(Base&)
TBase(Base&)
Derived(Derived&)
Am I missing something or is the compiler wrong?
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett
consider this:
#include <iostream>
struct Base {
Base() {std::cout << "Base\n";}
Base(Base&) {std::cout << "Base(Base&)\n";}
};
template< typename T >
struct TBase : Base {
TBase() : Base() {};
TBase(Base& obj) : Base(obj) {std::cout << "TBase(Base&)\n";}
};
struct Derived : TBase<int> {
Derived() : TBase<int>() {std::cout << "Derived()\n";}
Derived(Derived& obj) : TBase<int>(obj) {std::cout << "Derived(Derived&)\n";}
};
int main()
{
Derived d1;
Derived d2(d1);
return 0;
}
(Of course, this doesn' make sense. The real code
is a lot more complicated.)
Using VC7.1 this outputs
Base
TBase()
Derived()
Base(Base&)
Derived(Derived&)
whereas I would have expected
Base
TBase()
Derived()
Base(Base&)
TBase(Base&)
Derived(Derived&)
Am I missing something or is the compiler wrong?
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett