-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoo.h
30 lines (26 loc) · 975 Bytes
/
Foo.h
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
#pragma once
#include <memory>
#include <string>
struct MyStruct {
int x, y;
};
class Foo {
public:
virtual void ResetMyStruct(MyStruct& myStruct) = 0;
virtual const MyStruct CreateMyStruct(int x, int y) { return MyStruct{ x,y }; };
virtual const MyStruct CreateMyStruct(int x) { return MyStruct{ x,x }; };
virtual MyStruct MakeSpecialCopyMyStruct(const std::shared_ptr<MyStruct>& myStruct) const { return MyStruct{ myStruct->x, myStruct->y }; }
virtual MyStruct MakeSpecialCopyMyStruct(const MyStruct& myStruct) const { return MyStruct{ myStruct.x, myStruct.y }; }
virtual MyStruct MakeSpecialCopyMyStruct(MyStruct&& myStruct) const { return MyStruct{ myStruct.x, myStruct.y }; }
virtual int GetTen() { return 10; }
std::string GetString() { return "Original"; }
~Foo() {}
};
template<class T, class E>
class TemplatedFoo {
public:
virtual T Sum(T x, E y) = 0;
virtual T SumConst(T x, E y) const = 0;
virtual T Sum(T x, E y, T z) = 0;
~TemplatedFoo() {}
};