Error while Executing template Code

P

Pallav singh

Hi

can any one provide solution for it

Thanks
Pallav

---------------------------------------------------------------------------------------------------------------------------

template<typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template<typename T>
class DXTT : private BXT<T> {
public:

typename BXT<T>::Mystery * p;
template BXT<T>::template Magic<U> * plink;
// I am getting at this Line
// can anyone suggest Soltuion for it

};
 
V

Victor Bazarov

Pallav said:
Hi

can any one provide solution for it

Thanks
Pallav

---------------------------------------------------------------------------------------------------------------------------

template<typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template<typename T>
class DXTT : private BXT<T> {
public:

typename BXT<T>::Mystery * p;

OK said:
template BXT<T>::template Magic<U> * plink;

There is no 'U' in the context of this (DXTT) class. What is
'plink' supposed to be? A pointer to what? Since the type
'BXT<T>::Magic' is not really a type, but a *template*, you
cannot declare a pointer to it. You have to instantiate it
first. In your case 'Magic' needs the list of arguments, and
it should have only one element. What is it supposed to be?

If the argument for 'Magic' is, for instance, 'int', then the
declaration of 'plink' would be

typename BXT<T>::Magic<int> * plink;

But you have given _no_ indication what you want to use as the
argument for 'Magic' template. Perhaps your 'DXTT' template
needs to have two arguments, 'T' and 'U'?
// I am getting at this Line
// can anyone suggest Soltuion for it

};

V
 
A

Andrey Tarasevich

Pallav said:
template<typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template<typename T>
class DXTT : private BXT<T> {
public:
typename BXT<T>::Mystery * p;
template BXT<T>::template Magic<U> * plink;

Firstly, as Victor said already, there's no 'U' in this context.
Secondly, it is supposed to be

typename BXT<T>::template Magic<...whatever...>* plink;
^^^^^^^^
Note the first keyword: 'typename', not 'template'.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top