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 那么结果又是什么?

  • 相关阅读:
    使用JSONPath
    JSON 返回值JSONPath Syntax
    IntelliJ IDEA 打包Maven 构建的 Java 项目
    JMeter(7) 优化判断返回类型和返回值
    Windows copy
    Windows del
    Windows exit
    Windows netsh
    Windows start
    Windows taskkill
  • 原文地址:https://www.cnblogs.com/azbane/p/7613569.html
Copyright © 2011-2022 走看看