这样的写法是什么意思谁帮我看下?
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/08/12 17:35:17
这样的写法是什么意思谁帮我看下?
class Club{
string name;
Table members;
Table officers;
Date founded;
Club(const string& n,Date fd);
}
Club::Club(const string& n,Date fd)
:name(n),members(),officers(),founded(fd)
{
.
}
class Club{
string name;
Table members;
Table officers;
Date founded;
Club(const string& n,Date fd);
}
Club::Club(const string& n,Date fd)
:name(n),members(),officers(),founded(fd)
{
.
}
![这样的写法是什么意思谁帮我看下?](/uploads/image/z/12985800-24-0.jpg?t=%E8%BF%99%E6%A0%B7%E7%9A%84%E5%86%99%E6%B3%95%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%E8%B0%81%E5%B8%AE%E6%88%91%E7%9C%8B%E4%B8%8B%3F)
class Club{
string name;
Table members;
Table officers;
Date founded;
Club(const string& n,Date fd);
}
是Club类的声明
Club::Club(const string& n,Date fd)
:name(n),members(),officers(),founded(fd)
{
.
}
是类Club的构造函数.
冒号后面是类成员的初始化序列.就是说在执行大括号之间的代码之前,系统(编译器)已经要初始化Club类的每个成员.这个序列就是告诉编译器应该如何初始化类的成员.
string name;
Table members;
Table officers;
Date founded;
Club(const string& n,Date fd);
}
是Club类的声明
Club::Club(const string& n,Date fd)
:name(n),members(),officers(),founded(fd)
{
.
}
是类Club的构造函数.
冒号后面是类成员的初始化序列.就是说在执行大括号之间的代码之前,系统(编译器)已经要初始化Club类的每个成员.这个序列就是告诉编译器应该如何初始化类的成员.