Code demostrating "Distinguishing C++ Declarations from Expressions"_C/C++_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > C/C++ > Code demostrating "Distinguishing C++ Declarations from Expressions"

Code demostrating "Distinguishing C++ Declarations from Expressions"

 2011/1/3 9:17:55  yaojingguo  http://yaojingguo.javaeye.com  我要评论(0)
  • 摘要:Codedemostrating"DistinguishingC++DeclarationsfromExpressions"inTheDefinitiveANTLRReference.#include<stdio.h>typedefintI;charx='a';voidfoo(){I(x);x=10;printf("x=%dinfoo\n",x);}struct_node{intm;};typedefstruct_node*T;T(*a)(int);intmain(intargc
  • 标签:expression c++

Code demostrating "Distinguishing C++ Declarations from Expressions" in?The Definitive ANTLR Reference.

?

#include <stdio.h>

typedef int I;
char x = 'a';
void foo() {
  I(x);
  x = 10;
  printf("x = %d in foo\n", x);
}

struct _node {
  int m;
};

typedef struct _node * T;

T(*a)(int);
int main(int argc, const char *argv[]) 
{
  printf("cast %d, %d\n", I(x), (I)x);
  foo();
  printf("x = %d in main\n", x); 

  struct _node n;
  T one = &n;
  T *a = &one;

  T(*a)->m = 8;
  printf("m: %d\n", (*a)->m);
  return 0;
}
?
发表评论
用户名: 匿名