C++問題(15點)

2008-06-13 8:41 am
請問C++中...***iostream***係咩??...

聽人講係library...但係...***library***又係咩??...圖書館??=.="...資料庫??

咁***iostream***又裝左d咩??

點解一定要加***#include <iostream>***...??...這句有甚麼作用???...不打這句會有甚麼結果???

咁...***stdlib.h***又係咩??...

又係library???...咁***stdlib.h***又裝左d咩??

點解要加***#include <stdlib.h>**...??...這句有甚麼作用???...不打這句會有甚麼結果???

另外...***fstream.h***又係咩??...

這又是library???...咁***fstream.h***又裝左d咩??

點解要加***#include <fstream.h>**...??...這句有甚麼作用???...不打這句會有甚麼結果???

仲有仲有...***assert.h***又係咩??...

library???...咁***assert.h***又裝左d咩??

點解要加***#include <assert.h>**...??...這句有甚麼作用???...不打這句會有甚麼結果???

另外...***namespace***又係咩...?

***using namespace std;***這句入面既***std***又係乜東東??

*****using namespace std;*****這句有咩作用...??

回答 (1)

2008-06-14 3:01 pm
✔ 最佳答案
Library is a collection of some pre-written and pre-complied source code.

<iostream> is a common library for C++ . It contains cin, cout, ...

The header in form of <... .h> is C language library.
<stdlib.h> is the standard library for C language.
<fstream.h> is used to i/o something to a file.

<assert.h> contains only one function, i.e void assert(int). It is used to help debug. If argument passed is non-zero, nothing happens. If not, program abort and print which line this function is called.

If you forgot to #inlcude library, those things defined in that library cannot be used.

For the library content, you can search in the following website:
http://www.cplusplus.com/

namespace is a concept of C++.
namespace is a collection of name of function, class, ...
In C, all names defined in global namespace. They can be called directly.
In C++, all names in standard library is defined under std namespace. We must to import them to global namespace or local namespace before calling. Otherwise, they need to be called by adding [namespace]::[name]. e.g. std::cout

"using" is syntax to import the namespace.
using namespace std imports the whole namespace of std.


收錄日期: 2021-04-25 13:22:20
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080613000051KK00103

檢視 Wayback Machine 備份