I have the following c++ code:
#include <iostream>
#include <string>
int main( int argc, char* argv[] )
{
const std::string s1 = "ddd";
std::string s2( std::string( s1 ) );
std::cout << s2 << std::endl;
}
The result is: 1 Why? When I use -Wall flag, compiler write warning: the address of ‘std::string s2(std::string)’ will always evaluate as ‘true’
But this code:
#include <iostream>
#include <string>
int main( int argc, char* argv[] )
{
const std::string s1 = "ddd";
std::string s2( ( std::string )( s1 ) );
std::cout << s2 << std::endl;
}
The result: ddd
It's normal result