What is wrong in the following code:
Point2d.h
template <class T> class Point2D { private: T x; T y; ... };
PointsList.h
template <class T> class Point2D; template <class T> struct TPointsList { typedef std::vector <Point2D <T> > Type; }; template <class T> class PointsList { private: TPointsList <T>::Type points; //Compiler error ... };
I would like to create a new TPointsList user type without specifying a direct type ...
Add typename:
typename
... typename TPointsList<T>::Type points; ...
See Why do we need file_name here?
Have you tried using the typename keyword?
template <class T> class Points2DList { private: typename TPoints2DList <T>::Type points; //using the typename keyword ... };
, , , typename , :
typename typedef
, , Point2D Point2D. #include "Point2D.h" PointsList.h. , typename,
#include "Point2D.h"
TPointsList <T>::Type points; //Compiler error
typename TPointsList <T>::Type points;
TPoints2DList? .
TPoints2DList
, TPoints2DList struct, :
struct
private: struct TPointsList <T>::Type points; //should compile now
Source: https://habr.com/ru/post/1781508/More articles:Smart quotes do not display properly in email from phpmailer - phpIs there a standard way to link to an external website? - htmlHow can I defer jQuery.blur function? - javascriptC ++, data model, templates - c ++Getting list of strings with deleted character in permutation - pythonPassing a template class with an unknown type to an unoccupied class constructor - c ++Is there a GitX equivalent for Mercurial that allows command line execution? - command-lineSilverlight, C #: detect when there are no more images - c #Updating a media wiki article using Python? - pythonmySQL multiple INNER JOIN - inner-joinAll Articles