B
Bushido Hacks
When declaring a pointer to a single object in C++ the follwing code
is illegal:
Something* s;
s = new Something(); //ILLEGAL!
....
delete s;
The correct syntax is
Something* s;
s = new Something; //LEGAL
....
delete s;
Or if there is an argument
Something* s;
s = new Something(5.5); //LEGAL!
....
delete s;
When declaring a pointer to an array of objects, the following is
used.
Something* s;
s = new Something[3]; // LEGAL!
....
delete[] s;
What I would like to know is, is the following code legal?
Something* s;
s = new Something[1];
....
delete[] s;
Is is legal in C++ to create an array with just one object?
is illegal:
Something* s;
s = new Something(); //ILLEGAL!
....
delete s;
The correct syntax is
Something* s;
s = new Something; //LEGAL
....
delete s;
Or if there is an argument
Something* s;
s = new Something(5.5); //LEGAL!
....
delete s;
When declaring a pointer to an array of objects, the following is
used.
Something* s;
s = new Something[3]; // LEGAL!
....
delete[] s;
What I would like to know is, is the following code legal?
Something* s;
s = new Something[1];
....
delete[] s;
Is is legal in C++ to create an array with just one object?