-2
在這下面的代碼宏1總是細爲什麼宏在不使用名稱空間std的同時使用名稱空間std的方式有所不同?
但是,宏2不工作的if語句1不是written..why會出現這種情況?
#include<iostream>
#include<conio.h>
//using namespace std; //--statement 1
#define l std::cout<< //--macro 1
#define nl std::cout<<endl; //--macro 2
int main(){
l "testing";
nl // this is not working if i dont use statement 1
l "a new line";
getch();
return 0;
}
當語句1不寫入宏2是生產錯誤,指出
'[錯誤] ENDL未在此範圍聲明爲' 如果cout<<
是短版std::cout<<
,這個錯誤不應該發生......我不明白爲什麼會發生這種情況......
'endl'是'std'命名空間了。 – SingerOfTheFall
你只是錯過了在endl之前的std ::。它應該是** std :: endl; ** – banetl
所以你需要'std :: endl'。 –