PDA

View Full Version : using namespace คืออะไร



asylu3
07-12-2004, 12:23 AM
[code]
#include < iostream.h >
void main()
{

Anonymous
18-12-2004, 06:03 PM
[ Using Directive ]
เป็นการประกาศใช้ identifier ทุกตัวใน namespace นั้นๆ โดยที่ไม่ต้องระบุชื่อ namespace เช่น

using namespace std; /* all identifiers in std namespace will be using without explicit qualifier */
using namespace BlueBlood /* all identifiers in BlueBlood namespace will be using without explicit qualifier */

[ Using Declaration ]
คล้ายกับ using directive แต่ต่างกันตรงที่ using declaration จะเจาะจง identifier เป็นตัวๆไป เช่น

using std::cout; /* identifier cout will be using without explicit qualifier */
using BlueBlood::myVar; /* identifier myVar will be using without explicit qualifier */

Zedrixz
09-06-2009, 01:54 PM
using namespace BlueBlood /* all identifiers in BlueBlood namespace will be using without explicit qualifier */

BlueBlood คือ identifiers หรืออะไรหรอคับ ไม่เข้าใจบรรทัดนี้

Cyberking
12-06-2009, 06:37 PM
กำลังศึกษาอยู่พอดีครับ กำลังงง ว่า code แรก เป็น iostream.h อันหลัง ไม่มี .h
เพิ่มอีกนิดนึง ถ้าจะใช้คำสั่ง cout อย่างเดียวใช้ using std::cout; ก็ได้ครับ
ผิดพลาดยังไงติเตือนได้ครับ มือใหม่หัดเขียน :D