Created
January 1, 2015 16:59
-
-
Save lucidguppy/cc35eeb14f6000cf2b5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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