c++ - No matching function for call : const pointer to pointer -


i have following function declaration

int vectorquantization(const color **input, color **output,                        const int rows, const int cols, const int numcolors); 

and when try call main function error "no matching function call 'vectorquantization' ".

color *input2quantize; color *outputquantized; ... ... vectorquantization(&input2quantize, &outputquantized, rows, cols, 10); 

what trying make input of function constant cannot modified inside function , thought declaring constant make it. missing here? thinking using references instead pointer pointer, got confused. 2 questions:

  1. how can fix error?
  2. is better use references instead of const pointer pointer?

say this:

typedef color * colorptr;  colorptr input2quantize;  int vectorquantization(colorptr const * input);  vectorquantization(&input2quantize); 

if like, can spell function argument type out color * const * input, too.

note protects having function change pointer, not pointee, cannot protected, since have mutable pointer. if wanted, you'd need separate type:

typedef color const * safecolorptr;  safecolorptr safeinput = input2quantize;  int foo(safecolorptr const * pinput);  foo(&safeinput); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -