Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Default constructor & faulty warning
Default constructor & faulty warning [message #1746755] Fri, 04 November 2016 09:30 Go to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 142
Registered: February 2010
Senior Member
Hello,

If I have a class with some members, and a constructor which doesn't initialize some members, I get a warning in the GUI. Good.

But if I add to the constructor = default, I should have to initialize the members.
But I still get the warning.
Re: Default constructor & faulty warning [message #1750104 is a reply to message #1746755] Fri, 16 December 2016 07:50 Go to previous message
Nathan Ridge is currently offline Nathan RidgeFriend
Messages: 8
Registered: July 2009
Location: Canada
Junior Member
Your class probably has data members of built-in type.

Data members of built-in type remain uninitialized with a "= default" constructor, so the warning remains appropriate. In this case, a good way to avoid the warning is to give those members a default member initializer. For example:

  struct S {
      int i = 0;
   
      S() = default;  // no warning
  };
Previous Topic:ECLIPSE (CDT) Mars.1 cannot generate a proper project environment PATH for MINGW or CYGWIN
Next Topic:My title - a not very intelligent newbie.
Goto Forum:
  


Current Time: Thu Apr 25 09:01:58 GMT 2024

Powered by FUDForum. Page generated in 0.03211 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top