undefined symbol

Started by
1 comment, last by Nanoha 7 years, 9 months ago

Hi

why this undefined symbol error?

myList.h

class Ausfaelle {
public:
int index, active, color, height;
float drValue;
std::string label;
Ausfaelle(int index, int active, int color, float drValue, int height, std::string label);
};

extern bool compare (const Ausfaelle &ausfaelle1, const Ausfaelle &ausfaelle2);

second cpp:

Ausfaelle::Ausfaelle(int a, int b, int c, float d, int e, std::string f) {
index = a;
active = b;
color = c;
drValue = d;
height = e;
label = f;
}

bool compare (Ausfaelle &ausfaelle1, Ausfaelle &ausfaelle2)
{
return ( ausfaelle1.color < ausfaelle2.color );
}

main.cpp:

#include "myList.h"

Ausfalllinie[30].sort(compare);

Many thanks

Advertisement

What undefined symbol error? You only show source code


extern bool compare (const Ausfaelle &ausfaelle1, const Ausfaelle &ausfaelle2);

bool compare (Ausfaelle &ausfaelle1, Ausfaelle &ausfaelle2)

One has const, the other doesn't so they are considered different functions.

As long as they have the same signature it should work ok.


bool compare (const Ausfaelle &ausfaelle1, const Ausfaelle &ausfaelle2)
{
  return ( ausfaelle1.color < ausfaelle2.color );
}

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This topic is closed to new replies.

Advertisement