C++中的for语句问题&全文搜索的问题。(10分)

L

lps

Unregistered / Unconfirmed
GUEST, unregistred user!
1.下面一段来自msdn 98,另有一书说象下面的i的用法,在新旧C++标准中不一样。我的问题就是下面的用法是新还是旧的标准?
#include <iostream.h>
void main()
{
for( int i = 0;
i < 100;
++i )
cout << i << "/n";
// The loop index, i, cannot be declared in the
// for-init-statement here because it is still in scope.
for( i = 100;
i >= 0;
--i )
cout << i << "/n";
}
2.在msdn中找for竟然说:“帮助无法搜索此短语”,dfw的全文搜索也找不到,我知道这是所谓Stopwords的问题(Stopwords 是一些不独立表示意思的词。英文中有: is, are, at, this. 中文中有:和、的、地、得等。搜索Stopwords是费时且无用的,所以在index 中就排除了Stopwords ,这样数据库会更小更快)。
可是象for这个词在计算机科学中应该搜索到才对啊,请孙老师和soul等老大关注一下这个问题。
 
第一个搞清楚了,上面的是旧的标准。新标准是如下的:
#include <iostream.h>
void main()
{
for( int i = 0;
i < 100;
++i )
cout << i << "/n";
// The loop index, i, cannot be declared in the
// for-init-statement here because it is still in scope.
for(int i = 100;
i >= 0;
--i )//[red]注意此处重新定义了i[/red]
cout << i << "/n";
}
 
在VC可以像前一种写法(包括VC7),但在CB里这样是通不过编译的,这就是新旧的差异。说实话,在VC里一起可以按照前一种方法写,如果现在它突然不让这样干了,VC程序员就会觉得别扭,所以它也只有一条道走到黑。
在MSDN中不会找不到for的帮助吧,你在“索引”里输入“for keyword”
 
关于msdn我说的是[red]“搜索”[/red],索引当然能找到了,第一段就是来自msdn 98,主要是以前看书都是第二种,忽然看到这一段,当然要问个明白。
dfw的全文搜索也找不到for,[red]faint![/red]
 
接受答案了.
 
顶部