放牧代码和思想
专注自然语言处理、机器学习算法
    This thing called love. Know I would've. Thrown it all away. Wouldn't hesitate.

C++ static_cast 静态转型

static_cast类似于一个函数或者宏,能返回原始值类型转换后对应的值,一段例程:

#include <iostream>
using namespace std;

///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	float x = 1.2f;
	cout << static_cast<int>(x) << endl;
	system("pause");
	return 0;
}
///////////////////////////End Sub//////////////////////////////////
/************************************************************************/
/* output:
1
*/
/************************************************************************/

知识共享许可协议 知识共享署名-非商业性使用-相同方式共享码农场 » C++ static_cast 静态转型

评论 欢迎留言

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

我的作品

HanLP自然语言处理包《自然语言处理入门》