Possible Duplicate:
What is the difference between (type)value and type(value)?
If you have a function that takes an argument of type b, but at the call site you only have a variable of type a. Is there a difference between casting the function parameter from a to b, and constructing type b.
The specific example I am interested in is when there is no user defined cast operator, but there is a single argument constructor.
Example:
Function definition:
void DoWork(const B &arg1);
In my specific example type a is const char *
Call site:
DoWork((B)"Hello");
vs
DoWork(B("Hello"));
B class definition
class B
{
public:
B() : m_szValue(){}
B(const char *szValue) { strcpy (m_szValue, szValue); }
private:
char m_szValue[MAX_VALUE_LEN + 1];
};