C++11标准增加一部分非常好用而又人性化的化的东西,作为C++新手 有必要认真学习一下   对代码质量提高有很大帮助

本博客主要还是供自己学习使用

以下为主要测试代码

#include
   
    
#include
    
     
using namespace std;
int main()
{
#if 1
	cout << "类型别名测试 1.using 2.typedef" << endl;
	using double1 = double;
	typedef int int1;//+1
	double1 d = 3.156;
	int1 a = 222;
	cout << d << '\t' << a << endl;

	int a1 = 1, a2 = 2;
	auto sum = a1 + a2;
	cout << "auto测试 sum为整型变量" << endl;
	cout << "输出4   3" << endl;
	cout << sizeof(sum) << " " << sum << endl;
	int *p = &a1;
	decltype (p) b1;
	b1 = &a2;
	cout << "decltype测试 b1为指针变量" << endl;
	cout << b1 << " " << (*b1) << endl;

	cout << "getlineh函数对于string测试" << endl;
	string s1;
	getline(cin, s1);
	cout << "范围for测试" << endl;
	for (auto c : s1)
	{
		c = toupper(c);//字符串大写转换
		cout << c;
	}
#endif
#if 0
	//string内元素也可使用下标运算
	string str("hello world");
	if (!str.empty())
	{
		str[0] = toupper(str[0]);
		cout << str << endl;
	}
#endif

	system("pause");
	return 0;
}
    
   


版权声明:本文为null1132214759原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/null1132214759/article/details/70183175