DelphiFeeds.com

  • Dashboard
  • Popular Stories
  • Trending Stories
  • Feeds
  • Login
Trending now

HeidiSQL Is A Lightweight Open Source Database Management Tool Built In Delphi

Powerful Shipping Container Cargo Optimizer Built In Delphi FireMonkey

Modernizing Your Legacy Delphi Projects

Learn How to Use C++ Bidirectional Fences For Windows Development With C++Builder

Quickly Set Up Flexible Master-Detail Relationships Between Datasets In Delphi Apps

Quickly Create Robust Scalable Delphi Applications With Event Bus Framework

Learn How Easy It Can Be To Update Your C++ Builder Projects With The Embarcadero ...

Learn How Easy It Is To Connect To Microsoft SQL Server In Windows Delphi Development

Secrets Of Delphi: Discover This Obscure Delphi Character Syntax In This Learn Delphi Video

Learn How to Write Your Own Text Driver in This Learn Delphi Video

Learn More About The Powerful Macros Property Of IFDPhysCommand With FireDAC In Delphi

Learn About How To Use Non-static Data Member Initializers For Windows Apps In C++

1
Pabitra Dash Pabitra Dash 2 months ago in C++, cbuilder, Code, data member, initializer, Non-static, programming 0

Embarcadero Bcc32c and bcc32x (Clang-enhanced compiler for Win32) implements all of the ISO C++11 standard. It includes the use of non-static data member to be initialized where it is declared. The basic idea for C++11 is to allow a non-static data member to be initialized where it is declared (in its class). A constructor can then use the initializer when run-time initialization is needed.

#include <string>

struct B {
        B(int, double, double);
};

class A {
        int a = 7; // OK
        std::string str1 = "member"; // OK
        B b = {1, 2, 3.0}; //OK
        std::string str2("member");   // ill-formed
};

Why useful.
-Easier to write.
-You are sure that each member is properly initialized.
-You cannot forget to initialize a member like when having a complicated constructor. Initialization and declaration are in one place – not separated.
-Especially useful when we have several constructors.
-Previously we would have to duplicate initialization code for members.
-Now, you can do a default initialization and constructors will only do its specific jobs.

If a member is initialized by both an in-class initializer and a constructor, only the constructor’s initialization is done (it “overrides” the default).

Head over and find out more about C++ non-static data member initializers in the Embarcadero DocWiki!

Trending Stories

  • HeidiSQL Is A Lightweight Open Source Database Management Tool Built...

  • Powerful Shipping Container Cargo Optimizer Built In Delphi FireMonkey

  • Modernizing Your Legacy Delphi Projects

  • Learn How to Use C++ Bidirectional Fences For Windows Development...

  • Quickly Set Up Flexible Master-Detail Relationships Between Datasets In Delphi...

Embarcadero GetIt

  • Trial - TMS FlexCel for VCL & FMX

    Powerful, extensive and flexible component suite for native Excel report and file generation and […]

  • Trial - TMS Diagram Studio

    Communications package that provides access to the serial ports under Windows. The event-driven […]

  • Trial - TMS FMX UI Pack

    Single-source fully cross platform component set for desktop and mobile application development for […]

  • Trial - TMS FMX Cloud Pack

    TMS FMX Cloud Pack is a Delphi and C++Builder component library to seamlessly use all major cloud […]

  • Trial - TMS FNC Blox

    TMS FNC Blox offers cross-platform & cross-framework diagramming/flowcharting components for […]

  • Learn Delphi
  • Learn C++
  • Embarcadero Blogs
  • BeginEnd.net
  • Python GUI
  • Firebird News
  • Torry’s Delphi Pages
Copyright DelphiFeeds.com 2021. All Rights Reserved
Embarcadero
Login Register

Login

Lost Password

Register

Lost Password