Questions about double-pointers (int** q)

Does the “new” operator delete whatever the variable was assigned to?
Example:
1
2
3
Int p[3]={1,2,3};
p=new int[3];
//is delete[] p called? 


How can one assign the pointer to a two-dimensional pointer? (eg, I want an int** p to refer to the root pointer of int** q)

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Int** p=new int*[3];
for(int i=0;i<3;i++)
{
	p[i]=new int[3];
	for(j=0;j<3;j++)
		p[i][j]=i*3+j;
}//any shorter way to get a double pointer to a two-dimensional array?
//something more similar to int p[3][3]={{0,1,2},{3,4,5},{6,7,8}}; ?
int** q=new int*[2];
for(int i=0;i<2;i++)
{
	q[i]=new int[2];
	for(int j=0;j<2;j++)
		q[i][j]=3*j+i;
}
**p=**q;//is the old p deleted? 


Finally, I need two dimensional arrays in pointer form for a dynamic two-dimensional array wherein I do not want to use vectors. Is there any shorter way than what is shown above? Obviously the following does not compile:
 
int** f={{1,2,3},{4,5,6}};

which I suppose is a flexibility more than a curse, but is there something similar to it that would shorten what I need to write?
1
2
3
4
5
6
7
Int** p=new int*[2];
for(int i=0;i<2;i++)
{
	p[i]=new int[3];
	for(j=0;j<3;j++)
		p[i][j]=i*3+j+1;
}


Thank you for your time; these are questions I feel would be best asked programmers rather than searched for in a book.
Nope, that's how you have to use new on multi-dimensional arrays. Nothing stopping you from making a class that encapsulates a 1D array and treats it as 2D for simplicity, however.

You must manually delete[] anything you new[], just as you must delete anything you new. It will not be done automatically.
Thanks Zhuge for your quick response.
Topic archived. No new replies allowed.