-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA12-1-3.cpp
More file actions
66 lines (48 loc) · 1010 Bytes
/
A12-1-3.cpp
File metadata and controls
66 lines (48 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Rule: A12-1-3
// Source line: 17123
// Original file: A12-1-3.cpp
// $Id: A12-1-3.cpp 291949 2017-10-19 21:26:22Z michal.szczepankiewicz $
#include <cstdint>
#include <string>
class A
{
public:
A() : x(0), y(0.0F), str() // Non-compliant
{}
// ...
private:
std::int32_t x;
float y;
std::string str;
};
class B
{
public:
// ...
private:
std::int32_t x = 0;
float y = 0.0F;
std::string str = "";
// Compliant
// Compliant
// Compliant
};
class C
{
public:
C() : C(0, 0.0F, decltype(str)()) // Compliant
{}
C(std::int32_t i, float f, std::string s) : x(i), y(f), str(s)
{}
// ...
// Compliant
private:
std::int32_t x =
0;
// Non-compliant - there’s a constructor that initializes C
// class with user input
float y = 0.0F; // Non-compliant - there’s a constructor that initializes C
// class with user input
std::string str = ""; // Non-compliant - there’s a constructor that
// initializes C class with user input
};