zoukankan      html  css  js  c++  java
  • C++运算符优先级 案例1

    问:

                  ...

                  short nReaderCount=10
                  ++pLock->nReaderCount==?

                  ...

    ++和->同为1级优先级,我想很多也有很多新手弄不清楚这个例子先执行   ++    操作,还是先执行的  ->   操作

    我自己写个了短程序:

                  #include<iostream>
                  using namespace std;
                 

                  class test
                  {
                  public:
                      short nReaderCount;
                  };

                  int main()
                  {
                      test *test1=new test;
                      test1->nReaderCount=10;
        
                      cout<<    ++test1->nReaderCount    <<endl;
                      cout<<"结果表明:先执行指针操作,再执行自增操作";

                  return 0;
                  }

    追问:如果test是union 那么结果又是什么?

  • 相关阅读:
    OKHttp的使用
    多点触控
    事件分发机制的理解
    Activity的四种启动模式
    反射动态建表
    px,dp,sp三者的转换
    动态广播和静态广播的区别
    字符串转日期格式
    hive Metastore contains multiple versions
    记一次 qW3xT.4,解决挖矿病毒。
  • 原文地址:https://www.cnblogs.com/azbane/p/7613569.html
Copyright © 2011-2022 走看看