0
pls can sm1 explain dis code to me
#include <iostream> using namespace std; template <class T,int N> class mysequence{ T memblock [N]; public: void setmember(int x,T value); T getmember(int x); }; template<class T,int N> void mysequence <T,N>::setmember(int x,T value) { memblock[x]=value;} template <class T,int N> T mysequence<T,N>::getmember(int x) {return memblock[x];} int main() { mysequence <int,5> myints; mysequence <double,5> mydouble; myints.setmember(0,100); mydouble.setmember(3,3.1416); cout<<myints.getmember(0)<<'\n'; cout<<mydouble.getmember(3)<<'\n'; return 0; }
2 Answers
+ 3
This topic is covered in the C++ tutorial, keep reading the tutorial and practice. You will understand better once you get to the chapter about templates.
https://www.sololearn.com/learn/CPlusPlus/1914/
0
tanks