C ++我的函数调用有什么问题

时间:2013-04-04 10:04:04

标签: c++ visual-c++

在我的主要方法中有以下代码:

int main(int argc, char* argv[])
{

    Color c1(10,1,2); 
    HSL h=convertToHSL(c1);
    return 0;
}

使用以下convertToHSL方法:

HSL convertToHSL(Color const& c) {

   return HSL(0,0,0);
}

我的项目中出现了构建错误。 Color是一个定义如下的类:

Color::Color(){}
Color::Color(float r,float g,float b){
    this->r=r;
    this->g=g;
    this->b=b;
}

Color::~Color(void){}

HSL定义如下:

 HSL::HSL() {}
HSL::HSL(float h,float s,float l) {
    this->h=h;
    this->s=s;
    this->l=l;
}

HSL::~HSL(void){}

使用我已经提到的convertToHSL方法。

可能出现什么问题?

2 个答案:

答案 0 :(得分:1)

c1未声明。你的意思是

Color c1(10,1,2); 

答案 1 :(得分:0)

Color c1(10,1,2);?缺少对象名称c1

相关问题