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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:37:23+00:00 2026-05-24T09:37:23+00:00

newbie here, in order to help sort out problems in my C++ project, I

  • 0

newbie here, in order to help sort out problems in my C++ project, I am compiling with the -Weffc++ option in g++.

It’s giving me hundreds of warnings about “warning … should be initialized in the member initialization list”

Is this really necessary seeing as it will a) take a bit of time to write them all in, and b) make make things messier when I was happy initialising variables when they are need only.

But more specifically, how do I initialise a std::vector?

Is this the way, ie just putting a 0 in brackets?
My header:

class Blade;
class Postpro {
   public:
     Postpro(string fName) : theFileName(fName),
                             blade(NULL),
                             sizes(10),
                             t(std::vector<double>(0){};
     ~Postpro(){};
     void test();

   private:
     string theFileName;
     Blade* blade;
     int sizes;
     std::vector<double> t;
}

And then in the cpp I just resize the vector if I want to use it?

void Postpro::test() {
    blade = new Blade;
    t.resize(37);
}

Thanks

  • 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-24T09:37:24+00:00Added an answer on May 24, 2026 at 9:37 am

    You can do this the way you did it, but there is no point — the default constructor does exactly the same job. It is better to use initializer lists, but if it leads to unreadable or unnecessarily complicated code, it’s perfectly fine to initialize (to be more precise, reset them from their default values) the member variables in the constructor body.

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

Sidebar

Related Questions

newbie here, so thanks in advance for help! I have a Wordpress site with
Rails newbie here struggling with a small project. I am creating a simple ship
I'm probably making a newbie mistake here, but I can't figure out how to
Java Newbie here. I have a JFrame that I added to my netbeans project,
Newbie here! My problem is as follows: I have a dynamically populating ul where
Java newbie here, I am trying to find the output of the following chunk
this newbie here is smacking his head with webservices over Rails. Perhaps someone could
CSS newbie here. Strange thing is happening, I have gaps between links, and I
jQuery-newbie here. I want to do a simple horizontal scroll function with two buttons.
Im newbie here.I have a problem with codeigniter segment() method.I referred 6th segment of

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.