我有一个问题。没有构造函数的实例C++
“智能感知:没有构造的实例 “树::树” 的 参数列表参数类型相匹配:(浮动[3],浮[3],浮子,浮 ,整型,双,INT, INT)”。
第三行:
float ColorS[3]={1,1,1},ColorF[3]={1,0,0};
for(unsigned int i=0;i<20;i++){
Tree a(ColorS, ColorF,
5.0f, 5.0f,
rand()%180+90, 0.67,
rand()%4+2, rand()%6+2);
las.push_back(a);
a.cordx=rand()%50-25;
a.cordz=rand()%50-25;
}
那是我的类tree.h中:
class Tree{
.
.
.
Tree(float [3],float [3],float,float,float,int,int);
.
.
.
};
而这就是我的construcotor在Tree.cpp:
Tree::Tree(float fromColor[3], float toColor[3],
float h=5.0f, float angle=60*rad,
float ratio=0.67f, int amount=4,
int maxLevel=5){
.
.
.
===
编辑:现在我有这样的问题:
'树::树':没有重载函数有5个参数
下联:
for(unsigned int i=0;i<20;i++){
Tree a(5.0f, 1.0f,
0.67f, rand()%4+2,
rand()%6+2);
las.push_back(a);
a.cordx=rand()%50-25;
a.cordz=rand()%50-25;
}
这就是在树我的班.h:
class Tree{
...
Tree(float,float,float,int,int);
...
};
这就是我在Tree.cpp中的构造函数:
Tree::Tree(float h=5.0f, float angle=60*rad,
float ratio=0.67f, int amount=4,
int maxLevel=5){
...
}
我已经重新格式化了你的代码 - 你可以看到你正在调用一个带有8个参数的构造函数并且声明有7 – 2013-04-27 14:16:34
我已经重新编辑了你的问题,包括原始问题和新问题。如果问题完全不同,记住答案是没有意义的。您需要为将来阅读问答的人提供一些背景信息。 – 2013-04-27 15:31:59