PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Error while Executing template Code
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Error while Executing template Code

Réponse
 
LinkBack Outils de la discussion
Vieux 22/02/2008, 08h22   #1
Pallav singh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Error while Executing template Code

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

};

  Réponse avec citation
Vieux 22/02/2008, 15h03   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Error while Executing template Code

Pallav singh wrote:
> 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, this defines 'p' as a pointer to a BXT<T>::Mystery object.

> 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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  Réponse avec citation
Vieux 22/02/2008, 23h40   #3
Andrey Tarasevich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Error while Executing template Code

Pallav singh wrote:
>
> 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'.

--
Best regards,
Andrey Tarasevich
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08417 seconds with 11 queries