Skip to content

Instantly share code, notes, and snippets.

@yongjun823
Created November 9, 2018 09:14
Show Gist options
  • Select an option

  • Save yongjun823/e1d15eb05412bfe4bd37d18e191d657a to your computer and use it in GitHub Desktop.

Select an option

Save yongjun823/e1d15eb05412bfe4bd37d18e191d657a to your computer and use it in GitHub Desktop.
c++ template with class
/////
#include <iostream>
#include "arr.h"
template class Arrayy<int>;
template class Arrayy<double>;
template <typename T>
Arrayy<T>::Arrayy() {
}
template <typename T>
void Arrayy<T>::printT(T x) {
std:: cout << x << std::endl;
}
template <typename T>
class Arrayy {
public:
Arrayy();
void printT(T x);
private:
T* mass;
};
#include <iostream>
#include "arr.h"
int main() {
Arrayy<int> list1;
Arrayy<double> list2;
list1.printT(10);
list2.printT(10.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment