Reputation: 901
I am having trouble declaring a constructor from in a subclass whose superclass is created from a template.
The example code looks like this:
template <class T>
class foo{
public:
foo();
};
typedef foo<double> foo_double;
class bar : public foo_double
{
bar() : foo_double();
};
int main(){
}
when I compile, I get an error:
In constructor ‘bar::bar()’:
expected ‘{’ at end of input
I am at a bit of a loss here.
Upvotes: 0
Views: 1584
Reputation: 10998
You forgot the curly braces { }
bar() : foo_double() { }
// ^^^
Upvotes: 1
Reputation: 172894
Member initialize list can only be used with the constructor definition. So you need to define it as
bar() : foo_double() {}
And the base class will be default constructed by default, so you don't need to do it at all. Just
bar() {}
Upvotes: 6
Reputation: 10064
bar() : foo_double();
Is not a constructor.
bar() : foo_double() { }
is.
Upvotes: 1