Smart pointer, member variable

This commit is contained in:
Ciro Santilli 2017-09-24 14:24:51 +01:00
parent 7a3b3543fa
commit d4b082e4d6
3 changed files with 21 additions and 3 deletions

View File

@ -21,7 +21,7 @@ all: $(OUTS) $(OUTS_CPP)
gcc -O'$O' -g'$(G)' -o '$@' -pedantic-errors -std=c89 -Wextra '$<'
%$(OUT_EXT): %$(IN_EXT_CPP)
g++ -O'$O' -g'$(G)' -o '$@' -pedantic-errors -std=c++98 -Wextra '$<'
g++ -O'$O' -g'$(G)' -o '$@' -pedantic-errors -std=c++11 -Wextra '$<'
clean:
rm -f *$(OUT_EXT)

View File

@ -6,8 +6,9 @@ Method
class MyClass {
public:
void myMethod() {
std::cout << "My method" << std::endl;
int myVar;
int myMethod() {
return myVar + 1;
}
};

17
gdb/smart_pointer.cpp Normal file
View File

@ -0,0 +1,17 @@
/*
https://stackoverflow.com/questions/22798601/how-to-debug-c11-code-with-unique-ptr-in-ddd-or-gdb
*/
#include <memory> // unique_ptr
class MyClass {
public:
int myMethod() {
return 1;
}
};
int main() {
std::unique_ptr<MyClass> p(new MyClass());
p->myMethod();
}