This commit is contained in:
Mal 2022-10-08 21:01:53 +02:00
commit a4010b5b33
5 changed files with 49 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.o

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
template: template.cpp wtf.o
g++ -o template template.cpp wtf.o
wtf.o: wtf.cpp wtf.hpp
g++ -o wtf.o -c wtf.cpp

14
template.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
#include "wtf.hpp"
int main()
{
int number = 42;
Wtf<int> wtf(number);
std::cout << wtf.getTest() << std::endl;
return 0;
}

13
wtf.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "wtf.hpp"
template <typename T>
Wtf<T>::Wtf(T & test): test(test)
{
}
template <typename T>
T & Wtf<T>::getTest()
{
return this->test;
}

15
wtf.hpp Normal file
View File

@ -0,0 +1,15 @@
#ifndef __WTF__
#define __WTF__
template <typename T>
class Wtf
{
T & test;
public:
Wtf(T & test);
T & getTest();
};
#endif