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 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

Java Newbie here. I have a JFrame that I added to my netbeans project,
Newbie question here. I'm in the beginning stages of laying out a site in
I'm probably making a newbie mistake here, but I can't figure out how to
newbie here. This is an iPhone utility project. First things first. I have a
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
.NET newbie here... I'd like to make a button in a Windows form that
REAL newbie here to Objective C and Cocoa. I have this 'if statement' if
ASP.NET newbie here I have coded up an ASP.NET website and running on win'08
Extreme Android developer newbie here...well, new to Android development, not development in general. I
Pardon the dumb newbie question here; web programming isn't my forte... (blush) I 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.