Reputation: 1
Hello everyone having anissue with my code today. I have created a program calculating area of square circle and rectangle. With a base class of shape. Where the UML has shape as the abstract class with public area():double, getName():string,and getDimensions:string, rectangle derived from shape with protected height, and width, and a public rectangle(h:double, w:double), followed by a derived square from rectangle with just a public square(h:double), and finally a circle derived from shape with a private radius, and a public circle(r:double). So far have gotten far in my code yet in my shape.cpp file am getting an error on line 10 that says shape.cpp:10: error: definition of implicitly-declared 'constexpr shape::shape()' shape::shape()
here is a link to my complete code: https://gist.github.com/anonymous/0eedd7719a34655488fb
shape.cpp file:
#include "shape.h"
#include "circle.h"
#include "rectangle.h"
#include "square.h"
#include <QDebug>
#include <QString>
#include <iostream>
using namespace std;
shape::shape()
{
};
your help is appreciated
Upvotes: 0
Views: 11684
Reputation: 425
You need to add the shape()
constructor to your class declaration like this:
#ifndef SHAPE_H
#define SHAPE_H
#include <QString>
#include <QDebug>
using namespace std;
class shape
{
public:
shape();
virtual double area()=0;
virtual QString getName()=0;
virtual QString getDimensions()=0;
virtual~shape(){}
};
#endif
You can then create the definition in shape.cpp like this:
shape::shape()
{
}
without a semicolon at the end.
Upvotes: 4