473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

error C2027:Use of undefined type 'T'

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

May 8 '06 #1
2 5375
ro************@gmail.com wrote:
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;


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
May 8 '06 #2
Hi Tamas,

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

Best Regards,
Rohini Chandra

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ramkrishna.kulkarni | last post by:
Hello, Please see the code below. class A : public B<C,D,E> { // some data and member variables } class P : public Q<R,S>, public T
2
by: B_Love | last post by:
Hey! When trying to compile the code for a ordered vector class I get the following error: undefined reference to `WinMain@16' Anyone have any idea what I might be doing wrong? I've been...
4
by: r.nikhilk | last post by:
Hi, We are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by including the...
4
by: Mark | last post by:
Hi, I'm trying to write some classes that kind of manage themselves. A linked list, that links different types of objects. Here's the code... object.h: --- class Object { int alt;
1
by: Chifo | last post by:
I try to connect postgres database but browser showme a error"Fatal error undefined funtion pg_connect()" somebody can helpme ? i dont know whats means, all conection string its ok this is an...
3
by: sdeathstar | last post by:
I am working on IBM AIX machine and using XLC C++ complier version 8.0. 1) Able to compile the objects on AIX from C and C++ source code. 2) Able to create the libraries (combination of C & C++,...
2
by: kumarsatish | last post by:
The following C program in Turbo C is given the following error " Linker error:-Undefined Symbol _insert_point" #include<stdio.h> #include<conio.h> #define NULL 0 struct list_node
4
by: sanketiiit | last post by:
ERROR: Bloodshed Dev c++ undefined reference to cpu_features_init Perfect Solution to this error. If ( Installed MinGW ) then: 1. Uninstall MinGW 2. Delete manually MinGW Folder...
1
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="returnURL" id="returnURL" value="<?php print...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.