/*--------------------------------------------------------------------------------------*
 *                                                                                      *
 * ZAD - rozwiazanie                                                                    *
#include <memory>
#include <vector>
#include <iostream>

using namespace std;

/** klasa przykładowa, proszę jej nie modyfikować */
class Foo {
public:
	Foo(const string& s) : s_(s) {}
	int val() const { return s_.size(); }
private:
	string s_;
};

/** klasa przykładowa, proszę jej nie modyfikować */
class Goo {
public:
	Goo(int v) : v_(v) {}
	int val() const { return v_; }
private:
	int v_;
};

/** funkcja przykładowa, proszę jej nie modyfikować */
int add(const Foo& f, const Goo& g) {
	return f.val() + g.val();
}


Foo* createFoo(const string& s) {
	return new Foo(s);
}

Goo* createGoo(int i) {
	return new Goo(i);
}



int calc() {
	Foo* f = createFoo("x");
	Goo* g = createGoo(1);

	int out = add(*f, *g);

	delete f;
	delete g;

	return out;
}

/** rozwiązanie 1 : unique_ptr */
unique_ptr<Foo> createFoo_better(const string& s) {
	return unique_ptr<Foo>(new Foo(s));
}

unique_ptr<Goo> createGoo_better(int i) {
	return unique_ptr<Goo>( new Goo(i));
}

int calc_better1() {
	unique_ptr<Foo> f = createFoo_better("x");
	unique_ptr<Goo> g = createGoo_better(1);

	int out = add(*f, *g);
	return out;
}


/** rozwiązanie 2 : obiekty automatyczne */
int calc_better2() {
	Foo f("x");
	Goo g(1);

	int out = add(f, g);
	return out;
}


int main() {
	cout << calc() << endl;
	cout << calc_better1() << endl;
	cout << calc_better2() << endl;
	return 0;
}
