inheritace, virtual function

Hello everybody, i am beginner and im studing the inheritance, virtual fuction. and Im practising a console app about calculate Figure (Phere)

when Run this code, it issue any error as:
LNK2001 unresolved external symbol "public: virtual int __thiscall Figure::Volume(void)" (?Volume@Figure@@UAEHXZ)
LNK2001 unresolved external symbol "public: virtual int __thiscall Figure::Area(void)" (?Area@Figure@@UAEHXZ)
Help me to fix this code.

#include <iostream>
#include <windows.h>
#include <math.h>
#define M_PI 3.14159265358979323846 /* pi */

class Figure
{
public:
virtual int Area();// = 0;// pure virtual
virtual int Volume();// pure virtual
protected:
int m_radius;
int m_height;
int m_area;
int m_volume;
};
//////////////////////////////////////////////////////////////////////////
class Circle : public Figure
{
public:
Circle() {};
Circle(int radius);
int Area() override;
protected:

};
// constructor
Circle::Circle(int radius)
{
this->m_radius = radius;
}

int Circle::Area()
{
this->m_area = M_PI * pow(m_radius, 2);
return m_area;
}
//////////////////////////////////////////////////////////////////////////
class Sphere : public Circle
{
public:
Sphere() {};
Sphere(int radius);
int Area() override;
int Volume() override;
Circle* circle;
};
Sphere::Sphere(int radius)
{
this->m_radius = radius;
}
int Sphere::Volume()
{
this->m_volume = 4 / 3 * M_PI * circle->Area();
return m_volume;
}

//! main Function
int main(int argc, char* argv[])
{
Figure* obj_sphere = new Sphere(2); // parameter (radius)
std::cout << "Volume Sphere: " << obj_sphere->Area() << std::endl;
return 1;
}
Four problems:
1.) You did not define Figure::Area and Figure::Volume;
2.) You did not define Sphere::Area
3.) You did not make Circle methods virtual (not necessarily needed, since it is virtual by default, but still good to make them explicit)
4.) You did not use code tags: http://www.cplusplus.com/articles/jEywvCM9/
thank you so muchh.
I have fixed as you guided.
and problem 4, sorry for the inconvenience, i dont know why, when i take all of my code and then press "<>" button then it issue error website... i trying to several times but it same.
so I leave it.
You can always manually type in the words
[code]
and
[/code]
before and after your code block
Topic archived. No new replies allowed.