Created
September 30, 2014 16:25
-
-
Save katsuobushiFPGA/4a83d89c5482b9d45bb2 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
//Source.cpp | |
#include "Header.h" | |
#include <stdio.h> | |
int main(){ | |
Test<int> *t = new Test<int>(); | |
t->hello(); | |
t->setValue(2); | |
printf("getValue:%d", t->getValue()); | |
getchar(); | |
return 0; | |
} | |
//Header.h | |
//インターフェース | |
template <class T> class Test{ | |
public: | |
Test(); | |
~Test(); | |
void hello(); | |
void setValue(T v); | |
T getValue(); | |
private: | |
T value; | |
}; | |
//実装 | |
template <class T> | |
Test<T>::Test(){ | |
}; | |
template <class T> | |
Test<T>::~Test(){ | |
}; | |
template <class T> | |
void Test<T>::hello(){ | |
printf("hello\n"); | |
} | |
template <class T> | |
void Test<T>::setValue(T v){ | |
value = v; | |
}; | |
template <class T> | |
T Test<T>::getValue(){ | |
return value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
テンプレートの実装はヘッダに書かなければいけないらしい