Answer the question
In order to leave comments, you need to log in
Difference between the two designs?
What is the difference factor between these two?
cout << "Hello, World!";
// и
cout << string("Hello, World!");
Answer the question
In order to leave comments, you need to log in
cout << "Hello, World!";
uses the operator<< overload associated with a null-terminated "hello" character array, which is a const char[6], to a const char* when passed as an operator<< argument:
template< class CharT, class Traits >
basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os,
const char* s );
cout << string("Hello, World!"); использует оператор<< перегрузка для работы со строками.
string - это typedef для std::basic_string<char, std::char_traits<char>, std::allocator<char>>.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question