我有如下两个文件:
File: Num.h
class Num
{
private:
int num;
public:
Num(int n);
int getNum();
};
File: Num.cpp
#include"Num.h"Num::Num() : num(0) { }
Num::Num(int n): num(n) {}int Num::getNum()
{
return num;
}
我不理解Num::Num() : num(0) { }这条语句中的:num(0){}是什么含义。还有Num.cpp文件怎么处理Num.h的私有字段num?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4741/viewspace-3144095/ ,如需转载,请注明出处,否则将追究法律责任。