''之前的预期主要表达式

时间:2019-05-12 19:17:33

标签: c++

所以我有一个类和一个派生类。两者都需要构造函数,但是问题是派生类的构造函数出现错误。

class Property : public Space

Property::Property(int id, string name, SpaceType type, string actionText, int buyCost, int upgradeCost, PropertyCategory category): Space(int id, string name, SpaceType type, string actionText)
{
    this->buyCost = buyCost ;
    this->upgradeCost = upgradeCost ;
    this->category = category ;
    numberOfHouses = 0 ;
}

在构造函数'Property :: Property(int,std :: string,SpaceType,std :: string,int,int,PropertyCategory)':|

错误:'int'|

之前的预期主表达式

错误:“名称” |

之前的预期主表达式

错误:“类型” |

之前的预期主表达式

错误:“ actionText” |

之前的预期主表达式

1 个答案:

答案 0 :(得分:1)

只需使用参数调用超类构造函数即可:

  class BeatMapCell: UITableViewCell {

let cellView: UIView = {
    let view = UIView()
    view.backgroundColor = .white
    view.setCellShadow()
    return view
}()
let pictureImageView: UIImageView = {
    let iv = UIImageView()
    iv.contentMode = .scaleAspectFit
    iv.backgroundColor = .red
    return iv

}()
let titleLabel: UILabel = {
    let label = UILabel()
    label.text = "Name"
    label.textColor = UIColor.darkGray
    label.font = UIFont.boldSystemFont(ofSize: 16)
    return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    setUp()

}