for(auto &i:s)和for(auto i:s)区别

一、for(auto &i:s)和for(auto i:s)区别
代码1:

#include<iostream>
#include<string>
using namespace std;
string s = "hello";
for (auto &i : s ) //i是个引用 i到底引用的是什么?
	i = toupper(i); //改变成大写,影响s的值
	cout<<s<<endl; //s的值是 HELLO

代码2:

#include<iostream>
#include<string>
using namespace std;
string s = "hello";
for (auto i : s ) //书上说i 是char类型,那s[n]呢?
	i = toupper(i); //改变成大写,不影响s的值
	cout<<s<<endl; //s的值是 hello

二、auto 、static
auto 的对应类型不是使用 new 出来的变量,也不是static变量
auto 变量在函数结束时即释放了,再次调用这个函数时,又重新定义了一个新的变量。
static 变量是程序结束的时候才释放对象的,但它不需要手动释放。
static 如果在一个函数内申明,这每次进入这个函数时,还是使用第一次声明的变量,并且还保存的上次使用的值。
static 变量如果在结构和类中使用,这结构或类定义的一切对象,都将共享唯一 static 变量。

  • 6
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com Copyright © 2019 by John Wiley & Sons, Inc., Hoboken, New Jersey Published simultaneously in Canada Believe it or not, AutoCAD is almost 40 years old, having been born in December 1982, when most people thought that personal computers weren’t capable of industrial-strength tasks like CAD. The acronym stands for Computer-Aided Drafting, Computer-Aided Design, or both, depending on who you talk to. What’s equally scary is that many of today’s hotshot AutoCAD users, and most of the readers of this book, weren’t even born when the program frst hit the street and when the grizzled old-timer writing these words began using it. AutoCAD remains the king of the PC computer CAD hill by a tall margin, making it one of the longest-lived computer programs ever. It’s conceivable that the longterm future of CAD may belong to special-purpose, 3D-based software such as the Autodesk Inventor and Revit programs, or to specialized market-specifc variations built on top of AutoCAD. At any rate, AutoCAD’s DWG fle format is the de facto standard, and so AutoCAD will be where the CAD action is for the foreseeable future. You may have heard that AutoCAD is complex, and therefore is difcult to learn and use. Yes, the user interface includes about 1,300 icons. But it has been my observation that the easier any software is to learn and use, the sooner you bump up against its limitations. A car with no accelerator, one forward gear, no steering, and no brakes would be easy to use until you reached a hill, a curve, or a stop sign or you needed to back out of a parking space. Yes, AutoCAD is complex, but that’s the secret to its success. Some claim that few people use more than 10 percent of AutoCAD’s capabilities. Closer analysis reveals that most people use the same basic 5 percent and everyone else uses a different 5 percent after that. The trick is to fnd your 5 percent, the sweet spot that suits your particular industry. If you follow my advice, I think you will fnd that using AutoCAD is as simple and intuitive as driving a car. It should be perfectly clear that if your career path has put you in a position where you need to know how to use AutoCAD, you’re no dummy!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值