I am posing questions to prevent becoming trapped by making incorrect assumptions. That could bite me later.
There is a similarity in the general format of:
- int num; to declare a variable
- int num = 0; to initialize a variable
- int num(0); to initialize a variable
- return_type function_name(parameter) function header
- type function_name (parameter); function prototype
- int num = 0; and int num(0); are equivalent
- Using int num(0) can present confusion because:
- type function_name(parameter) can be identical to a function prototype.
- The absence of a semicolon is the only visible difference between a function header and int num(0);
In real life programming, is it a good idea to avoid int num(0) to avoid confusion?
Is the physical location of the statement coupled with the context with which it is presented always clear enough to distinguish the difference?
Thanks for your replies,