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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:04:31+00:00 2026-06-06T13:04:31+00:00

The following code doesn’t build. struct some_struct { some_struct() { … do something here

  • 0

The following code doesn’t build.

struct some_struct {
    some_struct() {
      ... do something here to specify size of v; how ??
    }
    enum {
       ZERO,
       ONE,
       TWO
    };

    static std::vector<std::string> v(TWO);
};

Appreciate any ideas.. nothing seems to suggest this is illegal use.

Typo: Fixed the vector syntax and correction: I have only tested on 2005/2008, not 2010. The error message for those who asked:

error C2061: syntax error : identifier 'TWO'

Further edit:

It looks like the compiler thinks v is a function that returns type std::vector<std::string>; all of this is inside a struct (I have now further corrected my post to clarify this some more). Perhaps I need to leave out the size argument which it confuses with a type and declare the size somewhere in the constructor? I meant for this vector to be a static data member of the struct. How do I get the compiler to understand this?

NOTE: On Linux I tested it on a standalone code resembling what I had up originally (without the struct)… so maybe it wouldn’t compile on Linux with this correction. So I removed the comment that it built OK on Linux. Apologies.

  • 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-06T13:04:34+00:00Added an answer on June 6, 2026 at 1:04 pm

    You can’t initialize the class member in the class declaration. You need to instantiate it outside:

    #include <vector>
    #include <string>
    
    struct some_struct {
        some_struct() {
        }
        enum {
           ZERO,
           ONE,
           TWO
        };
    
        static std::vector<std::string> v;
    };
    
    std::vector<std::string>
    some_struct::v = std::vector<std::string>(TWO);
    
    int main() {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code doesn't call the copy constructor. struct X { int x; X(int
I found interesting things.. Following code doesn't show @One and it show @Two after
following code doesn't work with input: 2 7 add Elly 0888424242 add Elly 0883666666
The following Code doesn't seem to work,I want the email keyboard with @ and
The following code doesn't work (of course), because the marked line does not compile:
The following code doesn't work! 'this' in in the context when i access it
I know why the following code doesn't compile: public class Main { public static
For some reason the following code doesn't work on Windows XP. new URL(file:// +
I'm wondering why the following code doesn't work: String test = new String(new byte[]
Setting onchange event for CheckBoxList using the following code doesn't work. chkListUserGroup.Attributes.Add(onchange, document.forms[0].isRecordModified.value='true';); How

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.