zoukankan      html  css  js  c++  java
  • C++初始化,之不明白篇 cout<<x<<endl 与 cout<<"x = "<<cout<<x<<endl的输出的值会不一样

    代码如下

    #include <iostream>
    using namespace std;

    class point
    {
    public :
        int x;
        int y;
        point()
        {
            x=0;
            y=0;
        }
        void output()
        {
            cout<<"x =";
            cout<<x<<endl;
            cout<<"y =";
            cout<<y<<endl;
            cout<<"x = "<<cout<<x<<endl;
            cout<<"y = "<<cout<<y<<endl;
        }
    };

    int main(int argc, char *argv[])
    {
        point pt;
        pt.output();
        return 0;
    }

     

    输入结果:


    x = 0
    y = 0
    x = 0x4453c40
    y = 0x4453c40
    请按任意键继续. . .

     

    cout<<x<<endl输出的数字

    cout<<"x = "<<cout<<x<<endl;输出的字符串,已经初始化为0,为何是0x4453c40

    疑问为何 cout<<x<<endl 与cout<<"x = "<<cout<<x<<endl的输出会不一样,请高手告之。

    编译环境为vs2008 与c-free,

  • 相关阅读:
    sql-编程语句
    数据库语句基础3
    数据库语句 2
    sql常用的语句
    SQL语句
    锚点链接...
    sqlserver 三大范式
    sqlserver 约束
    c#SQLserver数据类型
    c#中switch语句用法
  • 原文地址:https://www.cnblogs.com/ITBread/p/3656015.html
Copyright © 2011-2022 走看看