错误:“板::板”命名构造函数,而不是类型板::板;C++

error: ‘Board::Board’ names the constructor, not the type Board::Board; C++

本文关键字:类型 C++ 构造函数 错误      更新时间:2023-10-16

好吧,这是错误的代码,

板:

:板 {

}

那么,是什么让这个不编译呢?

在C++中,方法和函数具有以下语法:

<return-type> <class-name> :: <method-name> ( <arguments> ) { <statements> }

构造函数没有返回类型。

除此之外,您的函数定义如何匹配语法?

提示:

Board::Board()
{
}

注意:C++对其符号字符很挑剔。 ( 与 {.