Da das ganze ja C++ nach dem ISO-Standard ist, ging ich davon aus, daß das von QT-Creator unterstützt wird, dem ist aber leider nicht so.
Weil im Buch auch nur die Konsole von Bjarne Stroustrup verwendet wird, habe ich als Projekt ebenfalls eine reine C++ Anwendung ausgewählt.
Hier der Beweis
Inhalt der Projektdatei:
Code: Alles auswählen
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
shape.cpp
HEADERS += \
shape.h
Die Main:
Code: Alles auswählen
#include <iostream>
#include <shape.h>
using namespace std;
int main(int argc, char *argv[])
{
Circle *Kreis = new Circle(5, 5);
return 0;
}
Code: Alles auswählen
#ifndef SHAPE_H
#define SHAPE_H
class Shape {
public:
virtual void rotate(int) = 0;
virtual void draw() const = 0;
virtual bool is_closed() const = 0;
virtual ~Shape();
};
class Circle : public Shape {
public:
Circle(int p, int r);
void rotate(int) { }
void draw() const ;
bool is_closed() const { return true; }
private:
int point, radius;
};
#endif // SHAPE_H
Code: Alles auswählen
#include "shape.h"
Circle::Circle(int p, int r) {
point = p;
radius = r;
}
Trotz alledem kommen immernoch diese lästige Fehlermeldungen:
undefined reference to `Circle::Circle(int, int)'
undefined reference to `vtable for Shape'
Bereinigen und QMake alleine ausführen habe ich auch schon gemacht, da kam kein Fehler bei QMake, aber dann beim entscheidenen Erstellen bzw. Ausführen schonwieder undefinded reference to ......
Wie kann ich den QT-Creator dazu bringen, alles korrekt zu erstellen?