454,915 Members | 1,280 Online
Need help? Post your question and get tips & solutions from a community of 454,915 IT Pros & Developers. It's quick & easy.

# fabs problem on matrix variable

 P: n/a Using MSVC++ I get error C2665: 'fabs' : none of the 3 overloads can convert parameter 1 from type 'std::allocator<_Ty>::value_type' with [ _Ty=std::vector ] on code containing the following extract. void func(std::vector > *a ... double s ... scale = scale + fabs(a[k][i]); Jul 23 '05 #1
4 Replies

 P: n/a sa************@hotmail.com wrote: Using MSVC++ I get error C2665: 'fabs' : none of the 3 overloads can convert parameter 1 from type 'std::allocator<_Ty>::value_type' with [ _Ty=std::vector ] on code containing the following extract. void func(std::vector > *a ... double s ... scale = scale + fabs(a[k][i]); I assume scale/s is a typo. You're passing a pointer to a vector of vectors and treating it as a vector of vectors. Dereference it first (*a)[k][i], or pass a reference: void func(std::vector> &a) -- imalone Jul 23 '05 #2

 P: n/a sa************@hotmail.com wrote: Using MSVC++ I get error C2665: 'fabs' : none of the 3 overloads can convert parameter 1 from type 'std::allocator<_Ty>::value_type' with [ _Ty=std::vector ] on code containing the following extract. void func(std::vector > *a ... double s ... scale = scale + fabs(a[k][i]); Because a is a pointer to a vector of vectors of double. Hence, a[k][i] does not resolve to a double try the following declaration: void func(std::vector > &a) Jul 23 '05 #3

 P: n/a Ian Malone wrote: or pass a reference: void func(std::vector> &a) Sorry inner declaration > not > -- imalone Jul 23 '05 #4

 P: n/a That is an easier solution. Jul 23 '05 #5

### This discussion thread is closed

Replies have been disabled for this discussion.