| 1 |
|
| 2 |
#ifndef SP_H_ |
| 3 |
# define SP_H_ |
| 4 |
|
| 5 |
#include <string> |
| 6 |
#include <iostream> |
| 7 |
#include <memory> |
| 8 |
|
| 9 |
|
| 10 |
class Foo |
| 11 |
{ |
| 12 |
std::string m_datum; |
| 13 |
public: |
| 14 |
|
| 15 |
Foo () : m_datum ("") { |
| 16 |
std::cout << "Created empty foo" << std::endl; |
| 17 |
} |
| 18 |
|
| 19 |
Foo (std::string const &datum) : m_datum (datum) { |
| 20 |
std::cout << "Created foo with datum " << datum << std::endl; |
| 21 |
} |
| 22 |
|
| 23 |
const std::string get_datum () const { return m_datum; } |
| 24 |
|
| 25 |
void set_datum (std::string const &datum) { m_datum = datum; } |
| 26 |
|
| 27 |
virtual ~Foo() { |
| 28 |
std::cout << "Destroyed foo with datum " << m_datum << std::endl; |
| 29 |
} |
| 30 |
|
| 31 |
}; |
| 32 |
|
| 33 |
void function_that_takes_foo (std::shared_ptr<Foo> foo); |
| 34 |
std::shared_ptr<Foo> function_that_returns_foo (); |
| 35 |
|
| 36 |
#endif |