Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

for 迴圈...是否有新標準出現

0 views
Skip to first unread message

:>

unread,
Jan 7, 1997, 3:00:00 AM1/7/97
to

從 Borland C++ Builder 多多少少可以看到一些 ANSI C++ 的新標準

如 static casting、dynamic casting,typeid,STL 在 namespace std 內,
virtual constructor,標準的 bool, true, false、string class 等
很多好用的東西都不是 VC++ 4.2 或 BC++ 5.0 (更別說 Unix 上的 C++)
所能 Compile 的。

請試試

for(int i=0;i<100;i++) {} // do nothing
cout<<i;

在 VC++ 跑出來的結果是 100
赫然發現用 Borland C++ Builder 的結果是...
...

Compiling time error: unknown identifier 'i'
也就是說 i 的 scope 只在迴圈內
不知道是不是標準 ANSI C++ 定的新規定?

P.S. 前幾行如 bool, string, casting, virtual constructor...等
很多新東西其實我也不知道是不是「標準」的
直覺覺得是而已。要如何判斷呢?

shengw...@bbs.cis.nctu.edu.tw

unread,
Jan 7, 1997, 3:00:00 AM1/7/97
to

==> 在 tlj...@ms8.hinet.net (:>) 的文章中提到:

> 從 Borland C++ Builder 多多少少可以看到一些 ANSI C++ 的新標準
> 如 static casting、dynamic casting,typeid,STL 在 namespace std 內,
> virtual constructor,標準的 bool, true, false、string class 等
> 很多好用的東西都不是 VC++ 4.2 或 BC++ 5.0 (更別說 Unix 上的 C++)
> 所能 Compile 的。

其實最跟得上ANSI C++腳步的應該是 gcc 吧..這可是 unix 上的 compiler

> 請試試
> for(int i=0;i<100;i++) {} // do nothing
> cout<<i;
> 在 VC++ 跑出來的結果是 100
> 赫然發現用 Borland C++ Builder 的結果是...

> ....


> Compiling time error: unknown identifier 'i'
> 也就是說 i 的 scope 只在迴圈內
> 不知道是不是標準 ANSI C++ 定的新規定?
> P.S. 前幾行如 bool, string, casting, virtual constructor...等
> 很多新東西其實我也不知道是不是「標準」的
> 直覺覺得是而已。要如何判斷呢?

關於for的是新的標準沒錯, 其他我不大清楚..
不過, 看看最新版 gcc 的說明文件就知道了..不然看看
The C++ Programming Language, 2nd 後的 Appendix, 多少講了一些

Sheng-wey
--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>

四眼的王蟲

unread,
Jan 8, 1997, 3:00:00 AM1/8/97
to

tlj...@ms8.hinet.net (:>) wrote:

>
>for(int i=0;i<100;i++) {} // do nothing
>cout<<i;
>
>在 VC++ 跑出來的結果是 100
>赫然發現用 Borland C++ Builder 的結果是...
>...
>

>Compiling time error: unknown identifier 'i'
>也就是說 i 的 scope 只在迴圈內
>不知道是不是標準 ANSI C++ 定的新規定?
>
>P.S. 前幾行如 bool, string, casting, virtual constructor...等
> 很多新東西其實我也不知道是不是「標準」的
> 直覺覺得是而已。要如何判斷呢?
>

你提的 for loop 問題的確是 ANSI C++ 的新規定, 其他像 bool,
string, casting, namespace, rtti 等都是, 但是 virtual constructor
是指甚麼? C++ Builder 有這樣的文法嗎?

四眼的王蟲

--
生命是在黑暗中閃爍的光

0 new messages