Hi All,
I am a newbie and I need help with this (urgently if possible).
I am deriving a template class from QVector in order to add more functionality to be able to convert the types store in the QVector and also carry out math operations like multiplications.



Qt Code:
  1. #ifndef MVECTOR_H
  2. #define MVECTOR_H
  3. #include <QVector>
  4. #include <typeinfo>
  5. #include <QString>
  6.  
  7. template <typename T>
  8. class mVector:public QVector<T>
  9. {
  10.  
  11. bool numeric;
  12. public:
  13. mVector<T>():QVector<T>(){numeric=false;} //the vector contains non-numeric by default.
  14. mVector<T> operator*(mVector<T> a);
  15. bool isNumeric();
  16. mVector<float> toNumeric();
  17. mVector<QString> toString();
  18. mVector<T> operator=(mVector<T>);
  19. };
  20. #endif //
  21.  
  22.  
  23. #include "mvector.h"
  24.  
  25. template <typename T>
  26. mVector<T> mVector<T>::operator*(mVector<T> a){
  27. mVector<T> c;
  28. if(this->size()==a.size())
  29. {
  30. for(int i=0;i<a.size();i++)
  31. c[i]=this->at(i)*a[i];
  32. }
  33. return c;
  34. }
  35. template <typename T>
  36. bool mVector<T>::isNumeric(){
  37. return numeric;
  38. }
  39.  
  40. template <typename T>
  41. mVector<float> mVector<T>::toNumeric(){
  42. mVector<float> tm;
  43. if(!numeric){
  44. for(int i=0;i<this->size();i++)
  45. tm.append(float(this->at(i)));
  46. //this=&tm;
  47. }
  48. tm.numeric=true;
  49. return tm;
  50. }
  51.  
  52. template <typename T>
  53. mVector<QString> mVector<T>::toString(){
  54. mVector<QString> strv;
  55. if(numeric){
  56. for(int i=0;i<this->size();i++)
  57. {
  58. strv.append(QString::number(this->at(i)));
  59. }
  60. }
  61. strv.numeric=false;
  62. return strv;
  63. }
  64. template <typename T>
  65. mVector<T> mVector<T>::operator=(mVector<T> a){
  66. this->resize(a.size());
  67. for(int i=0;i<this->size();i++)
  68. *this[i]=a[i];
  69. return *this;
  70. }
To copy to clipboard, switch view to plain text mode 


creating an instance and calling any of its functions

Qt Code:
  1. mVector<QString> s;
  2. mVector<float> n;
  3. s.append("3.445");
  4. n=s.toNumeric();
To copy to clipboard, switch view to plain text mode 


gives this error. i included all dependencies to no avail.

./debug\mainwindow.o:L:\Qt Codes\LoadCombination\LoadCombination-build-desktop/../LoadCombination/mainwindow.cpp:156: undefined reference to `mVector<float>::operator=(mVector<float>)'


Thanks in advance for your intervention and help.