-
July 16th, 2013, 12:48 PM
#1
a simple question
Hi,
What is the difference between
and
Both gives the same output with
Thanks.
-
July 16th, 2013, 01:14 PM
#2
Re: a simple question
Originally Posted by manojg
Hi,
What is the difference between
and
Both gives the same output with
Thanks.
There is no difference. In C++, even though "a" is a simple double, for consistency it is advantageous for the syntax to initialize this variable to be similar to object initialization.
Code:
#include <string>
int main()
{
std::string s1("abc123");
std::string s2 = "abc123";
}
Note the similarities between the code above using the std::string class, and your code using the double.
Regards,
Paul McKenzie
-
July 16th, 2013, 04:05 PM
#3
-
July 18th, 2013, 11:11 AM
#4
Re: a simple question
Note that there may be a difference if the type is a class type rather than double, i.e., the former would not be allowed if the corresponding constructor was declared as explicit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|