为什么呼叫cout.operator<&书信电报;(const char*)是否打印地址而不是字符串? 我在C++中探索 oStase类。我被困在字符串和整数数据类型的cout的奇怪输出上

为什么呼叫cout.operator<&书信电报;(const char*)是否打印地址而不是字符串? 我在C++中探索 oStase类。我被困在字符串和整数数据类型的cout的奇怪输出上,c++,c++11,c++14,C++,C++11,C++14,传递整数值或浮点值时,输出正好是我传递的。例如cout.operator问题是,对于某些类型的operator当您执行cout.operator时,为什么要使用operator@NicolBolas我怀疑他们不知道该怎么做。我试图理解操作符的级联实际上是如何工作的,假设您没有使用这种形式的operatori尝试了打印字符串,但我的问题是,当它可以打印其他数据类型的相同结果时,为什么它会打印一些十六进制值?通常使用cout@RemyLebeau我删除了操作符 #include <iostre

传递整数值或浮点值时,输出正好是我传递的。例如
cout.operator问题是,对于某些类型的
operator当您执行
cout.operator时,为什么要使用
operator@NicolBolas我怀疑他们不知道该怎么做。我试图理解操作符的级联实际上是如何工作的,假设您没有使用这种形式的operatori尝试了打印字符串,但我的问题是,当它可以打印其他数据类型的相同结果时,为什么它会打印一些十六进制值?通常使用
cout@RemyLebeau我删除了
操作符
#include <iostream>
#include <string>

using namespace std;

int main() {
        const char* str = "aia";
        cout.operator<<(str);
        return 0;
}
operator<<(cout, str);
cout.operator<<(num);
basic_ostream& operator<<( short value );
basic_ostream& operator<<( unsigned short value );

basic_ostream& operator<<( int value );
basic_ostream& operator<<( unsigned int value );

basic_ostream& operator<<( long value );
basic_ostream& operator<<( unsigned long value );

basic_ostream& operator<<( long long value );
basic_ostream& operator<<( unsigned long long value );

basic_ostream& operator<<( float value );
basic_ostream& operator<<( double value );
basic_ostream& operator<<( long double value );

basic_ostream& operator<<( bool value );

basic_ostream& operator<<( const void* value );

basic_ostream& operator<<( std::nullptr_t );

basic_ostream& operator<<( std::basic_streambuf<CharT, Traits>* sb);

basic_ostream& operator<<(
    std::ios_base& (*func)(std::ios_base&) );

basic_ostream& operator<<(
    std::basic_ios<CharT,Traits>& (*func)(std::basic_ios<CharT,Traits>&) );

basic_ostream& operator<<(
    std::basic_ostream<CharT,Traits>& (*func)(std::basic_ostream<CharT,Traits>&) );
cout << str;