W
WittyGuy
Is there any difference between the following two snippets of code?
snippet1:
int main()
{
int* p = new int(5); // With argument for initialising p to the
value 5
....
....
....
delete p;
return 0;
}
snippet2:
int main()
{
int* p = new int; // Simply allocate memory in free store for p
*p = 5;
....
....
....
delete p;
return 0;
}
thanks,
--Wg-
snippet1:
int main()
{
int* p = new int(5); // With argument for initialising p to the
value 5
....
....
....
delete p;
return 0;
}
snippet2:
int main()
{
int* p = new int; // Simply allocate memory in free store for p
*p = 5;
....
....
....
delete p;
return 0;
}
thanks,
--Wg-