Using the new operator and calling a class constructor on the same line
Posted on 1998-03-13
Today I stumbled upon something new and I was wondering if there are any
problems with doing this..
Assume I have a class called temp....
cin >> input;
PtrToClassTemp = new PtrToClassTemp(input);
this will now call the constructor of class temp passing input as an
I am used to seeing the use of new as follows
variable = new type[size];
I knew I could always allocate class objects with new, but passing a value
to the constructor where the size of the memory to be allocated is odd to
Is there any problems with doing this? Anything to be concerned about (is
this a bad technique)? Should I just stay away from doing this? I posted this to the newsgroups and I got a mixed response of answers. Some said this was illegal and some said it was ok. What is the final answer...