Я должен был создать шаблон класса 2D матрицы.но оператор индекса (LINE 13,14,16 ~ 36) не может работать нормально.
Если я отмечу LINE 72 ~ 74 (dio.cpp), программа может быть запущена.LINE 91 ~ 93 МОЖЕТ работать.
Если LINE 72 ~ 74 (dio.cpp) не отмечает.Сбой Complie и IDE вызывают ошибку «вызов неисправности» (BCB5 E2314)
Нужна ваша любезная помощь!
Спасибо
BR
Evyyos
001 //[mtrx.h]======================================================================
002 class mtrx
003 {
004 private:
005 unsigned int _row;
006 unsigned int _col;
007 T** _m;
008 public:
009 mtrx();
010 mtrx(unsigned int, unsigned int);
011 ~mtrx();
012 ... ...
013 T& operator()(unsigned int row, unsigned int col);
014 T operator()(unsigned int row, unsigned int col) const;
015 ... ...
016 //c++ subscript operator
017 template<class T> inline T&
018 mtrx<T>::operator () (unsigned int row, unsigned int col)
019 {
020 if((row < this->_row) && (col < this->_col)){
021 return this->_m[row][col];
022 }
023 }
024
025 //c++ subscript operator
026 template<class T> inline T
027 //mtrx<T>::operator () (int row, int col) const
028 mtrx<T>::operator () (unsigned int row, unsigned int col) const
029 {
030 //if((row < this->_row) && (col < this->_col)){
031 // return this->_m[row][col];
032 //}
033 if((row < _row) && (col < _col)){
034 return _m[row][col];
035 }
036 }
037 //==============================================================================
038
039 //[dio.h]======================================================================
040 ... ...
041 #include "..\..\include\mtrx.h"
042 ... ...
043 unsigned long
044 dio_csv_analysis(
045 const char *ifile_name,
046 double smapling_ratio,
047 char fs,
048 unsigned int nn_selected_mask_size,
049 vector <int> inn_input_mask,
050 vector <int> inn_target_mask,
051 mtrx<double> *inn_input_stat,
052 mtrx<double> *inn_target_stat
053 );
054 ... ...
055 //==============================================================================
056
057 //[dio.cpp]====================================================================
058 ... ...
059 unsigned long
060 dio_csv_analysis(
061 const char *ifile_name,
062 double smapling_ratio,
063 char fs,
064 unsigned int nn_selected_mask_size,
065 vector <int> inn_input_mask,
066 vector <int> inn_target_mask,
067 mtrx<double> *inn_input_stat,
068 mtrx<double> *inn_target_stat
069 )
070 {
071 ... ...
072 inn_input_stat(nn_input_mask_id, NN_INPUT_AVG) = f_item; <<Compile ERR:: all of nonfunction
073 inn_input_stat(nn_input_mask_id, NN_INPUT_MAX) = f_item; <<Compile ERR:: all of nonfunction
074 inn_input_stat(nn_input_mask_id, NN_INPUT_MIN) = f_item; <<Compile ERR:: all of nonfunction
075
076 ... ...
077 //==============================================================================
078
079 //[global.h]======================================================================
080 ... ...
081 #include "dio_csv.h"
082 ... ...
083 //==============================================================================
084
085 //[main.cpp]====================================================================
086 ... ...
087 mtrx<double> nn_input_stat(nn_input_mask_size, 3);
088 mtrx<double> nn_target_stat(nn_target_mask_size, 3);
089 ... ...
090 double m=9,n=5,k=0;
091 nn_input_stat(0,0) = m; <<RUN TIME:: can work normally
092 nn_target_stat(0,0) = n; <<RUN TIME:: can work normally
093 n = nn_target_stat(0,0) - nn_input_stat(0,0); <<RUN TIME:: can work normally
094 ... ...
095 row_count=
096 dio_csv_analysis(
097 dio_csv_file.c_str(),
098 sampling_ratio,
099 ',',
100 nn_selected_mask_size,
101 nn_input_mask,
102 nn_target_mask,
103 &nn_input_stat,
104 &nn_target_stat
105 );
106 ... ...
107 //==============================================================================