Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
employee.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#
ifndef
EMPLOYEE_H
5
#
define
EMPLOYEE_H
6
7
//! [0]
8
#
include
<
QSharedData
>
9
#
include
<
QSharedDataPointer
>
10
#
include
<
QString
>
11
12
class
EmployeeData
:
public
QSharedData
13
{
14
public
:
15
EmployeeData
() :
id
(-1) {}
16
EmployeeData
(
const
EmployeeData
&other)
17
:
QSharedData
(
other
),
id
(other
.
id
),
name
(
other
.
name
) {}
18
~
EmployeeData
() =
default
;
19
20
int
id
;
21
QString
name
;
22
};
23
24
class
Employee
25
{
26
public
:
27
//! [1]
28
Employee
() { d =
new
EmployeeData; }
29
//! [1] //! [2]
30
Employee
(
int
id,
const
QString &name) {
31
d =
new
EmployeeData;
32
setId
(
id
)
;
33
setName(name);
34
}
35
//! [2] //! [7]
36
Employee
(
const
Employee
&other) =
default
;
37
Employee
&
operator
=(
const
Employee
&other) =
default
;
38
39
Employee
(
Employee
&&other) =
default
;
40
Employee
&
operator
=(
Employee
&&other) =
default
;
41
42
~
Employee
() =
default
;
43
44
//! [7]
45
//! [3]
46
void
setId
(
int
id) { d->id = id; }
47
//! [3] //! [4]
48
void
setName
(
const
QString &name) { d->name = name; }
49
//! [4]
50
51
//! [5]
52
int
id
()
const
{
return
d->id; }
53
//! [5] //! [6]
54
QString
name
()
const
{
return
d->name; }
55
//! [6]
56
57
private
:
58
QSharedDataPointer<EmployeeData> d;
59
};
60
//! [0]
61
62
#
endif
EmployeeData
[0]
Definition
src_corelib_tools_qshareddata.cpp:11
EmployeeData::~EmployeeData
~EmployeeData()=default
EmployeeData::name
QString name
Definition
employee.h:21
EmployeeData::EmployeeData
EmployeeData()
Definition
employee.h:15
EmployeeData::id
int id
Definition
employee.h:20
EmployeeData::EmployeeData
EmployeeData(const EmployeeData &other)
Definition
employee.h:16
Employee
[0]
Definition
doc_src_containers.cpp:10
Employee::Employee
Employee()
Definition
doc_src_containers.cpp:12
Employee::operator=
Employee & operator=(Employee &&other)=default
Employee::name
QString name() const
Definition
src_corelib_tools_qhash.cpp:129
Employee::Employee
Employee(int id, const QString &name)
[1] //! [2]
Definition
employee.h:30
Employee::operator=
Employee & operator=(const Employee &other)
Employee::Employee
Employee(const Employee &other)
Employee::~Employee
~Employee()=default
Employee::id
int id() const
Definition
doc_src_qcache.cpp:8
Employee::setName
void setName(const QString &name)
Employee::setId
void setId(int id)
Employee::Employee
Employee(Employee &&other)=default
main
int main()
[open]
Definition
doc_src_objecttrees.cpp:7
qtbase
src
corelib
doc
snippets
sharedemployee
employee.h
Generated on
for Qt by
1.18.0