Hi All,
i have some problem in pointers
here is my sample code.
Code:
/***predict.cpp********/
Array1D<REAL> CUnscXPredictor::CopyToArray1D(TXMatrix* inmatrix)
{
.
.
Array1D<REAL> amatrix(inmatrix->NumRows*inmatrix->NumColumns,inmatrix->aData); //line 1661
return amatrix;
}
Code:
/********olux.h*********/
typedef struct tagTMatrix1
{
long NumColumns;
long NumRows;
long NumPlanes;
float* aData; /
} TXMatrix;
Code:
/*****tnt_array1d.h****/
template <class T>
Array1D<T>::Array1D(long n, T *a) : v_(a), n_(n) , data_(v_.begin())
{
#ifdef TNT_DEBUG
std::cout << "Created Array1D(int n, T* a) \n";
#endif
}
compiler is reporting error in line 1661 because of 2nd argument passed to the object.
predictor.cpp:1661: error: no matching function for call to âTNT::Array1D<double>::Array1D(long int, float*&)â
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:107: note: candidates are: TNT::Array1D<T>::Array1D(const TNT::Array1D<T>&) [with T =
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:135: note: TNT::Array1D<T>::Array1D(long int, T*) [with T = double]
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:125: note: TNT::Array1D<T>::Array1D(long int, const T&) [with T = doub
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:117: note: TNT::Array1D<T>::Array1D(long int) [with T = double]
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:104: note: TNT::Array1D<T>::Array1D() [with T = double]
1> im having doubt at 2nd argument
inmatrix->aData
imatrix will finally points to address of aData
and this address will be passed to 2nd parameter of the below constructor which is a pointer type
Array1D<T>::Array1D(long n, T *a) : v_(a), n_(n) , data_(v_.begin())
{
}
hence address is passed to pointer but why compiler is raising error
2> im having doubt at 2nd parameter of error message
predictor.cpp:1661: error: no matching function for call to âTNT::Array1D<double>::Array1D(long int, float*&)â
../inc/../inc/../../corenumeric/inc/utils/../jama/../tnt/tnt_array1d.h:107
but when i replace the line 1661 with
float *ptr=inmatrix->aData;
Array1D<REAL> amatrix(inmatrix->NumRows*inmatrix->NumColumns,*ptr);
compiler wont report error.
plz guide what's the concept behind it and help me to fix this error..............
waiting for your reply.........