-2

头文件是这样的:

#include "Lib110ct.h"
class Circle
{
protected:
    double mx, my, mdx, mdy, mradius;
public:
    Circle(){}
    Circle(double x,double y,double dx,double dy,double rad):mx(x),my(y),mdx(dx),mdy(dy),mradius(rad){}
    void setPos(double x, double y){mx=x;my=y;}
    void setDir(double dx, double dy){mdx=dx; mdy=dy;}
    void setRadius(double rad){mradius=rad;}
    double getX(){return mx;}
    double getY(){return my;}

    void draw(Turtle * t);
    void clear(Win110ct& win);
    void move();
    bool collides(Circle & c);
};

#include "shape.h"

int main(int argc, char** argv)

    {
        Win110ct win;
        Turtle * t = win.getTurtle();
            Circle Circle;
            Circle.setPos(100, 300);
            Circle.setRadius(12);
            getX();
            getY();
            Circle.draw(t);

         return 0;
    }

它给我的错误信息是:

C:\Users\Oluwaseun\Documents\110ct\challenge2\programming\programming\main.cpp|13|未定义引用 `Circle::draw(Turtle*)'|

我究竟做错了什么?

4

1 回答 1

1

你需要定义

void draw(Turtle * t);

请看一下:http ://www.cprogramming.com/declare_vs_define.html

基本上,您在为其编写代码时定义一个函数:

void draw(Turtle* t) {  
    // code here
}
于 2013-04-22T23:37:21.430 回答