Advertisement Jump to content
Sign in to follow this  
FGFS

undefined symbol

This topic is 922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

 

Share this post


Link to post
Share on other sites
Advertisement
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 );
}
Edited by Nanoha

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!