Skip to content

Commit 38d8b5f

Browse files
Initial
0 parents  commit 38d8b5f

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

Diff for: README

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is a simple test case to show a flaw in C++ object copy behavior, used in this G+ discussion: https://plus.google.com/u/0/104959288284643103419/posts/WH4aUJEdxZt
2+

Diff for: compile.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
g++ -Wall test.cpp -o test
2+
chmod +x test
3+
./test
4+

Diff for: test.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
3+
class A {
4+
public:
5+
virtual void test() {
6+
std::cout << "A" << std::endl;
7+
}
8+
};
9+
10+
class B: public A {
11+
public:
12+
virtual void test() {
13+
std::cout << "B" << std::endl;
14+
}
15+
};
16+
17+
A getA() { return A(); }
18+
A getB() { return B(); }
19+
20+
int main() {
21+
getA().test();
22+
getB().test();
23+
return 0;
24+
}
25+

0 commit comments

Comments
 (0)