Hi all.
I've a problem with the void*. I explain it:
I want to have a dynamic array and I want to decide with "int t" if it must be float or unsigned short.Code:void leggi_vettore(void* & v, int n, int t){ if(t==1){ v = new float[n]; }else if(t==0){ v = new unsigned short[n]; }else cout << "Error!"; for (int i=0 ; i<n ; i++){ cout << "Inserimento in posizione [ " << i << " ]: "; cin >> v[i]; } }
When I did "cin >> v[i];" the compiler makes this error: "void* is not a pointer to object type".
What I can do?



LinkBack URL
About LinkBacks


