导航:首页 - c++中typedef类型定义的用法

c++中typedef类型定义的用法
作者:深圳教育在线 来源:www.szedu.net 更新日期:2010-3-18

  c++中typedef类型定义的用法,typedef,为"类型定义",可以解释为:将一种数据类型定义为某一个标识符,在程序中使用该标识符来实现相应数据类型变量的定义。

  总结一下,常用之处

  1: 定义函数指针

  #include "stdafx.h"

  #include

  #include

  using namespace std;

  typedef void (*F)(int);

  void print1(int x){

  cout<

  }

  int main(){

  F a;

  a = print1;

  (*a)(20);

  }

  2:简单类型替换:

  #include "stdafx.h"

  #include

  #include

  using namespace std;

  typedef int I;

  int main(){

  I a;

  a = 10;

  //a = "a";//false

  cout<

  }

  3:定义数组类型:

  #include "stdafx.h"

  #include

  #include

  using namespace std;

  typedef int A[3];

  int main(){

  A b = {3,4,5};

  cout<

  }


报 名 此 课 程 / 咨 询 相 关 信 息
【预约登门】 【网上咨询】 【订座试听】 【现在报名】
课程名称
c++中typedef类型定义的用法
真实姓名
* 性 别
联系电话
* E-mail:
所在地区
咨询内容

      

相关文章:

Copyright© 2004-2017 www.szedu.net 深圳教育在线 版权所有
中国·深圳
粤ICP备06023013号