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 8609797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:58:04+00:00 2026-06-12T03:58:04+00:00

Problem is as follow: The following test throws huge amounts of compiler errors. #include

  • 0

Problem is as follow: The following test throws huge amounts of compiler errors.

#include <vector>
using namespace std;

template<class T>
class test{
   vector<T> vec;
public:
   vector<T>::iterator begin();

};

template<class T>
vector<T>::iterator test<T>::begin(){
  return vec.begin();
}

int main(){

  test<float> testing;
  testing.begin();

}

Some Compiler errors:

 test.cpp(8): warning C4346: 'std::vector<T>::iterator' : dependent name is not a type
 test.cpp(8): error C2146: syntax error : missing ';' before identifier 'begin'
 test.cpp(13): error C2143: syntax error : missing ';' before 'test<T>::begin'

However, if you swap out the templated vector<T> for say, vector<float> its compiles just fine. For example:

template<class T>
class test{
   vector<T> vec;
public:
   vector<float>::iterator begin();

};

template<class T>
vector<float>::iterator test<T>::begin(){
   return vec.begin();
}

Any ideas as to why?

  • 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-12T03:58:05+00:00Added an answer on June 12, 2026 at 3:58 am

    You need to add typename in two places:

    typename vector<T>::iterator begin();
    

    and

    typename vector<T>::iterator test<T>::begin()
    

    By adding typename, you are telling the compiler how to parse the code. Basically, by adding typename, you are telling the compiler to parse the declaration as a type.

    Please read Where and why do I have to put the “template” and “typename” keywords? for an in-depth explanation.

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

Sidebar

Related Questions

I am using trigger_error to throw errors in a custom class. My problem is
I have the following problem. I am using Reporting Services 2005 to create some
I'm getting the following problem with my functional test. mrbernz:mylife bernardleung$ ruby test/functional/forums_controller_test.rb .....
I am trying to solve the following codechef problem using scala. The statement of
This problem follows on from a previous question . When I run the following
I run into follow problem. Did I miss anything? Association.all().count() 1 Association.all().fetch(1) [Association(**{'server_url': u'server-url',
My given problem is follow: I have an object with x columns and every
This is a follow up to my previous question: Problem passing parameters via Iframe
I'm trying to follow the Django tutorial (for v1.1) here . the problem that
I cannot figure out this positioning problem in Firefox. It doesn't seem to follow

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.