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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:19:41+00:00 2026-05-30T09:19:41+00:00

I am currently working on implementing the constructor function for the vector class(my professor

  • 0

I am currently working on implementing the constructor function for the vector class(my professor said that we can leave out anything that uses an allocator). I used the reference website that my professor gave us to determine the format of the function: http://www.cplusplus.com/reference/stl/vector/vector/

I am getting some errors in my function. Two of the errors are:

syntax error: identifier ‘size_type’

‘value’ : undeclared identifier

Any idea why I would be getting these errors? Here is my code:

explicit vector (size_type n, const T& value= T())
{
    my_vect=new int x[2*n];
    for(int i=0; i<n; i++)
    {
        vect[i]=value;
        length++;
    }
}
  • 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-30T09:19:42+00:00Added an answer on May 30, 2026 at 9:19 am

    If you define your class in an .h file, then the = T() is the default value. When you implement the method in the .cpp or .cc file, you leave out the default value.

    size_type is not in global scope it seems, so you need to use the resolution operator to give it correct scope. It appears to be std::string::size_type. This is probably just a typedef for size_t. I see size_type in the STL containers, but I’ve never used it when creating my own classes.

    Also, as Dietmar Kühl mentioned, when using C++ templates, you need to decorate everything with template <typename T>

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

Sidebar

Related Questions

I'm currently working on a Google Maps project and am implementing a search function.
I am currently working on a application that will be implementing user customizable widgets
I'm currently working on implementing Lua into one of the applications that I'm working
I'm currently working on an upgrade to a project that extensively uses COM /
I'm currently working on implementing a fulltext search engine for one of our sites,
A little backstory, currently I'm working on implementing a triangle rendering system in Expression2
Am currently working on an application that requires users to submit posts and comments
I`m currently working out the design for simple graphic editor, who support trivial operations
I`m currently working on a script, and I have the following situation. function somnicefunction()
I'm currently working on implementing a logging system for a new Hadoop cluster I've

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.