[英]Initializer lists
point2d is a struct containing two double vars x and y. point2d是包含两个双变量x和y的结构。
Projectile::Projectile(Point2D p1, double x1, double y1){
: xVel(x1), yVel(x1), pos.x(p1.x), pos.y(p1.y) { }
}
Gives an error message saying expected expression at the : Any ideas, not a matter of data type because all are double? 给出错误消息,在处显示期望的表达式:任何想法,而不是数据类型的问题,因为所有都是双重的?
You have an extra set of braces that you need to remove: 您需要删除一组额外的花括号:
Projectile::Projectile(Point2D p1, double x1, double y1){ // <-- here
: xVel(x1), yVel(x1), pos.x(p1.x), pos.y(p1.y) { }
} // <-- here
Should be this instead: 应该是这样的:
Projectile::Projectile(Point2D p1, double x1, double y1)
: xVel(x1), yVel(x1), pos.x(p1.x), pos.y(p1.y) { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.