?
=?gb2312?B?wfXquw==?=
Hi, folks,
My g++ is of version 3.4.2, here is the code snippet:
#include <iostream>
using namespace std;
class Base {
protected:
Base() {
cout << "This is B\n";
}
};
template<typename T>
class Derived: public Base {
public:
Derived(){}
Derived(const Base& b): Base(b) {}
Derived<T> D() {
Base b;
return Derived<T>(b);
}
};
int main() {
Derived<int> obj;
obj.D();
return 1;
}
When I tried to build this program, an error arraised:
test.cpp:7: error: `Base::Base()' is protected
test.cpp:18: error: within this context
Any informative tips will be appreciated, thank you.
Best regards.
My g++ is of version 3.4.2, here is the code snippet:
#include <iostream>
using namespace std;
class Base {
protected:
Base() {
cout << "This is B\n";
}
};
template<typename T>
class Derived: public Base {
public:
Derived(){}
Derived(const Base& b): Base(b) {}
Derived<T> D() {
Base b;
return Derived<T>(b);
}
};
int main() {
Derived<int> obj;
obj.D();
return 1;
}
When I tried to build this program, an error arraised:
test.cpp:7: error: `Base::Base()' is protected
test.cpp:18: error: within this context
Any informative tips will be appreciated, thank you.
Best regards.