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

  • SEARCH
  • Home
  • 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 8789315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:22:21+00:00 2026-06-13T22:22:21+00:00

Possible Duplicate: Why do I need to use typedef typename in g++ but not

  • 0

Possible Duplicate:
Why do I need to use typedef typename in g++ but not VS?

I am defining a template class as follows

template <class T>
class MyVector : public std::vector<boost::shared_ptr<T>>
{
public:
   typedef MyVector::iterator MyIter;
};

I get this error at the typedef for MyIter

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I am compiling using VS 2010, I have made sure that the includes for vector and boost::shared_ptr are present. If I remove the template T and replace it with int everything compiles without error.

What am I missing? I want to define a template class and typedef the iterator.

  • 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-06-13T22:22:23+00:00Added an answer on June 13, 2026 at 10:22 pm

    This question is very well answered here:
    Why do I need to use typedef typename in g++ but not VS?

    But long story short, you must use the keyword typename in this way:

    typedef typename MyVector::iterator MyIter;
    

    Because in the first pass (verifying template syntax) the compiler doesn’t really know if MyVector::iterator is a type or a variable (what it is actually going to be on the specialized template). So hinting it that it is a type fixes the issue.

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

Sidebar

Related Questions

Possible Duplicate: Need help with getline() getline() is not working, if I use it
Possible Duplicate: C#: Public Fields versus Automatic Properties Do I need to use {
Possible Duplicate: JSON Parsing in Android As I find out I need to use
Possible Duplicate: Limit file format when using <input type=file>? I need to use the
Possible Duplicate: Why XML-Serializable class need a parameterless constructor Does anyone know if it
Possible Duplicate: How to use a WSDL file to create a WCF service (not
Possible Duplicate: Do I need to use mysql_close(connection)? Is it best to close a
Possible Duplicate: Where and why do I have to put the template and typename
Possible Duplicate: Need help with getline() I'm trying to use the getline function in
Possible Duplicate: Dictionary sorting by key length I need to use dictionary for search

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.