Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2006

Tip: Looking for answers? Try searching our database.

error C2027:Use of undefined type 'T'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rohinichandrap@gmail.com - 08 May 2006 18:07 GMT
Hi,

I am getting the error C2027:Use of undefined type 'T' when I tried to
compile some code in visual c++7.1 that went fine in Visual c++6.0.

Below is the relevant code where the error has come.
---------------------------------------------------------------------------­---------------------------------------------------------

template <class T>
class MCS_PersistentList
{
public:
/* typedef std::list<T> List;*/
  typedef std::list<class T> List;/*above line modified to the current

line to resolve C2146*/
  typedef List::iterator iterator;
  typedef List::const_iterator const_iterator;
.
.
.

}

class MCS_ADH_Device_Cfg
{
public:

int deviceNum;
.
.
.

}

typedef MCS_PersistentList<MCS_ADH_Device_Cfg> ADH_ConfigFile;

ADH_ConfigFile::iterator it;
int x = it->deviceNum;<------Error points to this line
---------------------------------------------------------------------------­-----------------------------------------------------------

Any kind of help is appreciated.
Thanks in advance.

Best Regards,
Rohini Chandra
Tamas Demjen - 08 May 2006 18:33 GMT
> template <class T>
> class MCS_PersistentList
[quoted text clipped - 6 lines]
>    typedef List::iterator iterator;
>    typedef List::const_iterator const_iterator;

The standard requires that you use the "typename" keyword to refer to
type names in your template:

template <class T>
class MCS_PersistentList
{
public:
   typedef std::list<typename T> List;
   // you must tell the compiler that T is a type name
   typedef typename List::iterator iterator;
   typedef typename List::const_iterator const_iterator;
   // you must tell the compiler that List::iterator and
   // List::const_iterator are type names

Tom
rohinichandrap@gmail.com - 09 May 2006 09:32 GMT
Hi Tamas,

Thank you very much for the suggestion.
It worked and the error does not show up.

Best Regards,
Rohini Chandra

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.