I was writing this simple polymorphism program:
Shape.h
Code:
#ifndef SHAPE_H
#define SHAPE_H
#include <string>
using namespace std;
class Shape
{
public:
virtual double getArea() const;
virtual double getVolume() const;
virtual string getName() const = 0;
virtual void print() const = 0;
};
#endif
Shape.cpp
Code:
#include <iostream>
#include "Shape.h"
using namespace std;
double getArea() const
{
return 0.0;
}
double getVolume() const
{
return 0.0;
}
When I compile Shape.cpp using Visual C++ 6.0 it come out with errors message:
Shape.cpp(7) : error C2270: 'getArea' : modifiers not allowed on nonmember functions
Shape.cpp(12) : error C2270: 'getVolume' : modifiers not allowed on nonmember functions