在C++中,這兩個沒有區別。C++沒有指針類型嗎?
char *pC;
char* pC2;
我以爲型焦炭和的char *都必須是不同類型和所有的C++程序員不得不用這種形式的char * P的代替字符* P,因爲當你做char * p它似乎沒有指定程序員正在使用指向char的指針。
但是,當您查看下面的代碼(與C++ 0x中的nullptr相同)時,T似乎無法識別任何指針類型。
const class{
public:
// T is char, not char* in this case.
// T* is char*, but I thought it would be char**
template <class T>
operator T*() const{
cout << "Operator T*() Called" << endl;
return 0;
}
template <class C, class T>
operator T C::*() const{
cout << "Operator C T::*() Called" << endl;
return 0;
}
private:
void operator&() const;
}AAA = {};
int main(){
// operator T*() const is called,
// but it's awkward,
// because it looks like T will be char* type, so T* will be char**
char* pC = AAA;
}
在此先感謝!
你的問題是什麼? – Beta
問題標題是無稽之談。顯然C++有指針類型,而且你知道它。 –