Witam, mam problemy przy kompilacji, wyrzuca mi taki błąd:
/tmp/cclBBvDw.o: In function `circuit_element::circuit_element()':
test.cpp:(.text._ZN15circuit_elementC2Ev[circuit_element::circuit_element()]+0xb): undefined reference to `vtable for circuit_element'
/tmp/cclBBvDw.o: In function `circuit_element::~circuit_element()':
test.cpp:(.text._ZN15circuit_elementD2Ev[circuit_element::~circuit_element()]+0xb): undefined reference to `vtable for circuit_element'
/tmp/cclBBvDw.o:(.rodata._ZTI9fotodioda[typeinfo for fotodioda]+0x8): undefined reference to `typeinfo for circuit_element'
collect2: ld returned 1 exit status
Niestety nie doszedłem o co chodzi w tym błędzie, dlatego prosiłbym o pomoc, oto mój kod:
Klasa abstrakcyjna circuit_element.h:
#include <iostream>
#include <string>
using namespace std;
struct colour
{
int R, G, B;
};
struct point
{
int x, y;
};
class circuit_element
{
protected:
string name;
colour wire_colour, bg_colour;
point center;
point * nodes_list;
int wire_width, width;
public:
string virtual elem_SVG();
void virtual set_wire_colour(colour&);
void virtual set_bg_colour(colour&);
void virtual set_wire_width(int);
void virtual set_width(int);
void virtual set_center(point&);
};
Klasa pochodna fotodioda.h:
#include <iostream>
#include <string>
using namespace std;
class fotodioda:public circuit_element
{
friend class wire;
public:
fotodioda(string s, colour& w, colour& bg, point& c, int w_width, int side, point& left_node, point& right_node)
{
name = s;
int nodes_num = 2;
nodes_list = new point[2];
nodes_list[0] = left_node;
nodes_list[1] = right_node;
wire_colour = w;
bg_colour = bg;
center = c;
wire_width = w_width;
width = side;
};
~fotodioda()
{
delete [] nodes_list;
};
string elem_SVG() {};
void set_wire_colour(colour& w) {wire_colour = w;};
void set_bg_colour(colour& bg) {bg_colour = bg;};
void set_wire_width(int w) {wire_width = w;};
void set_width(int w) {width = w;};
void set_center(point& p) {center = p;};
};
test.cpp:
#include <iostream>
#include "circuit_element.h"
#include "fotodioda.h"
using namespace std;
int main()
{
colour black = {black.R = 0, black.G = 0, black.B = 0};
colour white = {white.R = 255, white.G = 255, white.B = 255};
point punkt1 = {punkt1.x = 35, punkt1.y = 100};
point punkt2 = {punkt2.x = 135, punkt2.y = 200};
point punkt3 = {punkt3.x = 235, punkt3.y = 300};
point& ref1 = punkt1;
point& ref2 = punkt2;
point& ref3 = punkt3;
cout << "black: " << black.R << " " << black.G << " " << black.B << endl;
cout << "white: " << white.R << " " << white.G << " " << white.B << endl;
fotodioda dioda("dioda", black, white, ref1, 3, 80, ref2, ref3); // tu zdaje sie zamiast tych ref-ów mozna wstawic bezposrednio point
}