Skip to content

Instantly share code, notes, and snippets.

@lucidguppy
Created January 1, 2015 16:59
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 lucidguppy/cc35eeb14f6000cf2b5d to your computer and use it in GitHub Desktop.
Save lucidguppy/cc35eeb14f6000cf2b5d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <memory>
using namespace std;
class Foo {
public:
Foo(int a, int b) {
this->a = a;
this->b = b;
};
int sum() { return a+b;}
private:
int a;
int b;
};
void silly(Foo* aFoo) {
cout << "I like your foo\n";
cout << "Its sum is " << aFoo->sum() << "\n";
}
void billy(Foo& aFoo) {
cout << "I don't like your foo\n";
cout << "Its sum is " << aFoo.sum() << "\n";
}
int main() {
cout << "Hello\n";
auto myFoo = Foo(1,2);
cout << myFoo.sum() << "\n";
auto pFoo = make_unique<Foo>(3,4);
cout << "PFOO\n";
cout << pFoo->sum() << "\n";
silly(pFoo.get());
billy(*pFoo);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment