Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:04:39+00:00 2026-05-31T20:04:39+00:00

#include <list> template < class TYPE > class CIndex : protected std::list < TYPE

  • 0
#include <list>

template < class TYPE > 
class CIndex : protected std::list < TYPE >
{
public:
    typedef std::list < TYPE >::iterator  CIndexIt;
    typedef std::list < TYPE >::difference_type  CIndexDiff;

The error happens in the last line of the above code.

I’ve seen this and the msdn page but both don’t solve my error.

Anyone knows what could be causing the problem?

EDIT:
The reason the first link’s solution didn’t work was because although adding typename worked for the above code, it didn’t work for the below code:

#include<hash_map>
class CWItems
{
typedef stdext::hash_map < unsigned long, CWksItem* >   CItem;
CItem mItems;

So I thought I was doing the wrong thing by adding typename everywhere. Using typename after the typedef in this code caused this error:

error C2899: typename cannot be used outside a template declaration

Without typename, the error shown is error C4430: missing type specifier - int assumed. Note: C++ does not support default-int, at the CItem mItems; line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:04:40+00:00Added an answer on May 31, 2026 at 8:04 pm

    You need to add the typename keyword because std::list<TYPE>::iterator and std::list<TYPE>::difference_type are dependent names:

    typedef typename std::list < TYPE >::iterator  CIndexIt;
    typedef typename std::list < TYPE >::difference_type  CIndexDiff;
    

    See http://pages.cs.wisc.edu/~driscoll/typename.html for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <list> #include <set> #include <iterator> #include <algorithm> using namespace std; class MyContainer {
#include <list> #include <boost/tuple/tuple.hpp> template<class InputIterator> void f(InputIterator it) { typedef boost::tuple<typename InputIterator::value_type, int>
When I try to use my iterator class template<class T> class list { public:
Test.h #ifndef TEST_H #define TEST_H #include <memory> template <class Type> bool operator==(const std::weak_ptr<Type>& wp1,
#include<iostream> #include<time.h> #include<list> #include<stdlib.h> #include<fstream> using namespace std; typedef struct diskBtNode { int parent;
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\list(1194): error C2451: conditional expression of type 'void' is
#include <map> #include <list> template < typename K, typename V> class LruCache { private:
The code below gives the error: error: type ‘std::list<T,std::allocator<_Tp1> >’ is not derived from
#include <initializer_list> #include <utility> void foo(std::initializer_list<std::pair<int,int>>) {} template <class T> void bar(T) {} int
If I have this kind of hierarchy: #include <iostream> using namespace std; template<class T>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.