没有匹配的函数来调用'Street :: draw'

时间:2018-07-04 16:17:18

标签: c++ qt

street.h:

#include "city.h"

class Street
{
public:
    Street(City* c1_init, City* c2_init);
    ~Street();

    void draw(QGraphicsScene *scene) const;

private:
    City *c1;
    City *c2;
};

#endif // STREET_H  

street.cpp:

#include "street.h"

Street::Street(City* c1_init, City*c2_init):c1(c1_init), c2(c2_init)
{

}

Street::~Street()
{
}

void Street::draw(QGraphicsScene *scene) const
{
    QPen pen;
    pen.setColor(Qt::green);
    scene->addLine(c1->getX(), c1->getY(), c2->getX(), c2->getY(), pen);
}

现在我正在尝试这样做:

City *city1 = new City("Thomasberg", 44, 55);
City *city2 = new City("Wolken", 77, 100);

Street *landstrasse = new Street(city1, city2);
landstrasse->draw(grscene);  

定义了城市等级,没有问题。现在,它告诉我“没有匹配功能可调用'Street :: draw'”

有人知道吗?:)

1 个答案:

答案 0 :(得分:0)

我的错误是函数 draw 将指针作为输入:)