Void Pointer to generate 2D Array

Does anyone know how to use a void pointer to generate a 2D array rather than an int pointer?

For integer pointer, I do as follow:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int **m;

m = new int* [row];
	
for(int i=0; i< row; i++)
    m[i] = new int[col];

for (int i = 0; i < row; i++)
{
   for (int j = 0; j < col; j++)
   {
      m[i][j] = rand () % 10;
   }	
}	


What if the pointer type is void***m?

How can I define the storage like int? eg.(m = new int* [row];)

Thanks for your help.
Last edited on
If it's a void*** then you are on your way to becoming a three-star programmer.

http://c2.com/cgi/wiki$?ThreeStarProgrammer

In other words: don't.

1
2
3
4
5
6
tyepdef std::vector<void*> vec1d;
typedef std::vector<vec1d> vec2d;

vec2d m(row, vec1d(col, 0));

m[0][0] = new foo;

Hi PanGalactic!

Thanks for your reply. However, it's nothing related to the vector, It's just a pointer of void type to create 2 Dimensional Dynamic Array.

Would you please give a complete example so that I can understand clearer?

Cheers!
Nobody know the answer ???

Please...guys!
Topic archived. No new replies allowed.