Hi!
I have this code and getting this problem: undefined reference to 'vtable for Triangle'.
Thanks for your help!

#include<iostream>
using namespace std;

class Point
{
    public:
        float x,y;
        Point(){}
        Point(float x,float y):x(x),y(y){};
        Point operator=(Point &X);
};

Point Point::operator=(Point &X)
{
    this->x=X.x;
    this->y=X.y;
    return *this;
}

class Figure
{
    public:
        void status();
        virtual float area()=0;
        virtual float perimeter()=0;
};

void Figure::status()
{
    cout << "Area: " << area() << endl;
    cout << "Perimeter: " << perimeter() << endl;
}

class Triangle:public Figure
{
    private:
        Point A,B,C;
    public:
        Triangle(){};
        Triangle(Point& A, Point& B, Point& C){};
        float area();
        float perimeter();
};

int main()
{   
    Triangle T;

    return 1;
}

I figured out that problem was because I didn't declare the functions in class Triangle.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.