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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:17:07+00:00 2026-05-30T14:17:07+00:00

I have a struct called member . Within member I have a std::string array

  • 0

I have a struct called member. Within member I have a std::string array called months that I would like to initialize to default values. This is how I am doing it currently:

template <typenameT>                                                                                               
struct member                                                                                                       
{                                                                                                                   

    std::string months[12];                                                                                         
    std::string name;                                                                                               
    T hours_worked[12];                                                                                             
    T dues[12];                                                                                                     

    member() : months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} {};    
};

However, whenever I compile I get this warning message:

warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x 

How can I do the initialization properly and get rid of this error message?

Edit:

I should of made my question more clear. I need compile this program on a older compiler and the -std=c++0x flag option will not be available to me. How can I do this correctly without using the flag.

  • 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-30T14:17:08+00:00Added an answer on May 30, 2026 at 2:17 pm

    It tells you in the warning. Try adding -std=c++0x to your g++ arguments. If you want to be able to use this on an older compiler then you can’t use initialiser lists the way you are doing.

    Instead you could change member() to be something like

    member()
    {
      months[0] = "January";
      months[1] = "February";
      ...//etc
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a struct called foo_boolean that contains some boolean values: struct foo_boolean
I have a struct which contains a member called char *text. After I've created
I have a struct called Point. Point is pretty simple: struct Point { Row
I have a struct called coordinate which is contained in a list in another
I am trying to model a network using C++. I have a struct called
I have a struct as follows, with a pointer to a function called length
I have a list of Fruit structs called basket . Each Fruit struct has
Ok so I have struct like this typedef struct { float x; float y;
I have a struct defined like follows as part of an object. I'm trying
Let's say I've got a struct that consist of 100 bytes. What guarantees have

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.