Ich habe die folgende Quelle Druck istIst der Standardwert eines int * NULL?
#include <iostream>
using namespace std;
template <class T>
class AAA
{
public:
void f() { cout << T() << " "; }
};
int main (void)
{
AAA<int*> a;
AAA<int> b;
a.f(); /// in this case, T() == NULL??
b.f();
return 0;
}
und Konsole geschrieben 00000000 0 (in Visual Studio 2010)
wenn T int * ist, T() == NULL? und ist es immer wahr?
Yup. Immer. http://StackOverflow.com/a/937257/707111 – Ryan
möglich Duplikat von [Was ist der Standardkonstruktor für C++ Zeiger?] (http://StackOverflow.com/questions/936999/what-is-the-default-constructor -für-c-pointer) – Troubadour