Skip to content

Commit ddb6a85

Browse files
committed
get error to appear
1 parent d0cbce1 commit ddb6a85

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
testapp
2+
13
# Prerequisites
24
*.d
35

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ cd ..
66

77
mv lib/*.so .
88

9-
g++ -std=c++17 -L. -ltest -Wl,-rpath='${ORIGIN}' -o testapp testapp.cpp
9+
g++ -std=c++14 -L. -ltest -Wl,-rpath='${ORIGIN}' -o testapp testapp.cpp
1010

lib/Test.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,19 @@ void printStructInfo11()
1717
<< ") n: (" << &(b.n) << ") o(" << &(b.o) << ")\n";
1818

1919
}
20+
21+
void printStruct2Info11()
22+
{
23+
24+
std::cout << "\nC++ 11\n";
25+
A2 a;
26+
std::cout << "Size of A2: " << sizeof(A2) << '\n';
27+
std::cout << " Memory locations: m(" << &(a.m)
28+
<< ") n: (" << &(a.n) << ")\n";
29+
30+
B2 b;
31+
std::cout << "Size of B2: " << sizeof(B2) << '\n';
32+
std::cout << " Memory locations: m(" << &(b.m)
33+
<< ") n: (" << &(b.n) << ") o(" << &(b.o) << ")\n";
34+
35+
}

lib/Test.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ struct B : public A
1313

1414
void printStructInfo11();
1515

16+
struct A2
17+
{
18+
uint16_t m{3};
19+
bool n;
20+
};
21+
22+
struct B2 : public A2
23+
{
24+
bool o;
25+
};
26+
27+
void printStruct2Info11();
28+

testapp

-16.3 KB
Binary file not shown.

testapp.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,27 @@ void printStructInfo14()
1818

1919
}
2020

21+
void printStruct2Info14()
22+
{
23+
std::cout << "\nC++ 14\n";
24+
A2 a;
25+
std::cout << "Size of A2: " << sizeof(A2) << '\n';
26+
std::cout << " Memory locations: m(" << &(a.m)
27+
<< ") n: (" << &(a.n) << ")\n";
28+
29+
B2 b;
30+
std::cout << "Size of B2: " << sizeof(B2) << '\n';
31+
std::cout << " Memory locations: m(" << &(b.m)
32+
<< ") n: (" << &(b.n) << ") o(" << &(b.o) << ")\n";
33+
34+
}
2135
int main()
2236
{
2337

2438
printStructInfo11();
2539
printStructInfo14();
2640

41+
printStruct2Info11();
42+
printStruct2Info14();
2743
}
2844

0 commit comments

Comments
 (0)