umbrello: test/import/cxx/cxx11-object-construction-improvement.h Source File

umbrello 25.08.0 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

cxx11-object-construction-improvement.h
Go to the documentation of this file.
1// https://en.wikipedia.org/wiki/C%2B%2B11#Object_construction_improvement
2
3// #1
4 class SomeType {
5 int number;
6
7public:
8 SomeType(int new_number) : number(new_number) {}
9 SomeType() : SomeType(42) {}
10};
11
12// #2
13 class BaseClass {
14public:
15 BaseClass(int value);
16};
17
18 class DerivedClass : public BaseClass {
19public:
20 using BaseClass::BaseClass;
21};
22
23// #3
24 class SomeClass {
25public:
26 SomeClass() {}
27 explicit SomeClass(int new_value) : value(new_value) {}
28
29private:
30 int value = 5;
31};
32
BaseClass::BaseClass
BaseClass(int value)
DerivedClass
Definition cxx11-object-construction-improvement.h:18
DerivedClass::BaseClass
BaseClass(int value)
SomeClass::SomeClass
SomeClass(int new_value)
Definition cxx11-object-construction-improvement.h:27
SomeClass::SomeClass
SomeClass()
Definition cxx11-object-construction-improvement.h:26
SomeClass::value
int value
Definition cxx11-object-construction-improvement.h:30
SomeType::SomeType
SomeType(int new_number)
Definition cxx11-object-construction-improvement.h:8
SomeType::number
int number
Definition cxx11-object-construction-improvement.h:5
SomeType::SomeType
SomeType()
Definition cxx11-object-construction-improvement.h:9