K
Keith MacDonald
The code below fails to compile with VC7.1 and GCC 3.2.3, when the line
labelled BAD is used, instead of the line immediately after it. The error
from VC7.1 is "no appropriate default constructor available". However, it
will compile with VC8, so is the BAD line valid C++?
Thanks,
Keith MacDonald
template<typename T>
class Base
{
public:
Base(T n)
: val_(n)
{}
T val_;
};
template<typename T>
class Derived
: public Base<T>
{
public:
Derived(T n)
// BAD : Base(n)
: Base<T>(n)
{}
};
int main()
{
Derived<int> d(7);
return 0;
}
labelled BAD is used, instead of the line immediately after it. The error
from VC7.1 is "no appropriate default constructor available". However, it
will compile with VC8, so is the BAD line valid C++?
Thanks,
Keith MacDonald
template<typename T>
class Base
{
public:
Base(T n)
: val_(n)
{}
T val_;
};
template<typename T>
class Derived
: public Base<T>
{
public:
Derived(T n)
// BAD : Base(n)
: Base<T>(n)
{}
};
int main()
{
Derived<int> d(7);
return 0;
}