Accessing types in base class?

N

none

I have this base class:


template<typename J>
class Processor {
public:
const unsigned int Dimension = J::Dimension;
typedef typename J::ImageType ImageType;

Processor ();
virtual ~Processor ();

};
#endif


In a sub class I need to use the types from the base class:


template <typename J>
class SubProcessor : public Processor<J>{
public:

void test(ImageType image) {
// do stuff

}

};

But that is not possible! The base class type "ImageType" is not visible in the sub class. In the
sub class I could just do the same as in the base class:

typedef typename J::ImageType ImageType;

but what is the point of using inheritance then?
 
A

Abhishek Padmanabh

none said:
I have this base class:


template<typename J>
class Processor {
public:
const unsigned int Dimension = J::Dimension;
typedef typename J::ImageType ImageType;

Processor ();
virtual ~Processor ();

};
#endif


In a sub class I need to use the types from the base class:


template <typename J>
class SubProcessor : public Processor<J>{
public:

void test(ImageType image) {
// do stuff

}

};

But that is not possible! The base class type "ImageType" is not visible
in the sub class. In the sub class I could just do the same as in the base
class:

typedef typename J::ImageType ImageType;

but what is the point of using inheritance then?

You would need to do something like this, although the initialization of the
const member in the base class is not valid, (and hence commented out):

template<typename J>
class Processor
{
public:
//const unsigned int Dimension = J::Dimension;
typedef typename J::ImageType ImageType;
Processor ();
virtual ~Processor ();
};
template <typename J>
class SubProcessor : public Processor<J>
{
public:
void test(typename Processor<J>::ImageType image) {
// do stuff
}
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top