Skip to content

Instantly share code, notes, and snippets.

@bruceoutdoors
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruceoutdoors/40a79d4d210e9606344f to your computer and use it in GitHub Desktop.
Save bruceoutdoors/40a79d4d210e9606344f to your computer and use it in GitHub Desktop.
Used for tutorial: http://wp.me/p2N4HD-1L
#include <iostream>
#include <memory>
#include <string>
#include "Point.hpp"
class PointMan
{
public:
PointMan() : q(new Point("q")) {
q->set(6, 12);
p = std::make_shared<Point>("p");
p->set(q->getX()+3, q->getY()+2);
int r_x = q->getX() + p->getX();
int r_y = q->getY() + p->getY();
r = Point::UPtr(new Point("r"));
r->set(r_x, r_y);
}
void print() {
std::cout << "My Point 'p': " << p->toString() << "\n"
<< "My Point 'q': " << q->toString() << "\n"
<< "My Point 'r': " << r->toString() << "\n";
}
private:
Point::SPtr p;
Point::UPtr q;
Point::UPtr r;
};
int main()
{
PointMan man;
man.print();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment