3.1 定义类型

Posted: March 25, 2011 in C++

/*有时需要频繁的使用比如unsigned short int等等类型, 即繁琐又容易出错, 所以可以用typedef来定义,
语法是type+类型+新名称*/

#include <iostream>

using namespace std;

typedef unsigned int i;

void main()
{
          i a=1, b=3; //这里用到了typedef, 可以省略unsigned int.
          cout<<a+b<<endl;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s