我创建了一本书课,作为我作业的一部分,我正在学习它,但它似乎有一个问题,我在下面的代码中无法理解,这是我的代码
private:
Book (string N = " ", int p = 100, string A = "",
string P = "", string T = "", int Y = 2000)
{
cout << "Book constructor start " << N << endl;
Title=N;
pages=p;
Author=A;
Publisher=P;
Type=T;
Yearpublished=Y;
}
~Book(void)
{
cout << "Book destructor start " << Title << endl;
system("pause");
}
public:
static Book * MakeBook(string N = "", int p = 100, string A = "",
string P = "",string T = "",int Y = 2000)
{
return new Book(N,p,A,P,T,Y);
}
static void DelBook(Book * X) {
delete X;
}
在上面的代码中是构造函数和析构函数,我的问题是当我NULL
在函数中传递 a 作为参数时会发生什么stactic void DelBook
?像下面这样
static void DelBook(NULL)
{
delete NULL;
}
如果可以传递 NULL 值,我该如何编译?提前致谢。