Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Sep 28, 1999

Templates

Question:
I'm porting a UNIX app to NT; one of the class hierarchies includes something like this:

template 
class base
{
    // stuff
};

template 
class derived :
    public base,
public base { // stuff };
When I compile it in MSVC6 I get the following error:

c:\projects\test\test.cpp(14) : error C2500: 
'derived' : 'base'
is already a direct base class c:\projects\test\test.cpp(17) : see reference to class
template instantiation 'derived' being compiled
How can I get around this?

Answer:
Your code is prefectly legal and should compile on every ANSI/ISO compliant compiler. Unfortunately, MS VC6.0 is not fully compliant yet and therefore, it refuses to compile this snippet. I would suggest using another compiler instead, such as Borland C++ Builder 4.0 for example (which blissfully compiles this code).

Alternatively, you can modify your code but it seems like you will need to do a lot of work because the changes will affect other components and classes that use class 'derived'.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap