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
|
// -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode:nil; -*-
#ifndef SP_H_
# define SP_H_
#include <string>
#include <iostream>
#include <memory>
class Foo
{
std::string m_datum;
public:
Foo () : m_datum ("") {
std::cout << "Created empty foo" << std::endl;
}
Foo (std::string const &datum) : m_datum (datum) {
std::cout << "Created foo with datum " << datum << std::endl;
}
const std::string get_datum () const { return m_datum; }
void set_datum (std::string const &datum) { m_datum = datum; }
virtual ~Foo() {
std::cout << "Destroyed foo with datum " << m_datum << std::endl;
}
};
void function_that_takes_foo (std::shared_ptr<Foo> foo);
std::shared_ptr<Foo> function_that_returns_foo ();
#endif /* !FOO_H_ */
|