Possible Duplicate:
Do the parentheses after the type name make a difference with new?
Hello all,
class Car
{
public:
Car() : m_iPrice(0) {}
Car(int iPrice) : m_iPrice(iPrice) {}
private:
int m_iPrice;
};
int _tmain(int argc, _TCHAR* argv[])
{
Car car1; // Line 1
Car car2(); // Line 2, this statement declares a function instead.
Car* pCar = new Car; // Line 3
Car* pCar2 = new Car(); // Line 4
return 0;
}
Here is my question:
When we define an object of Car, we should use Line 1 rather than Line 2. When we new an object, both Line 3 and Line 4 can pass the compiler of VC8.0. However, what is the better way Line 3 or Line 4? Or, Line 3 is equal to Line 4.
Thank you