I follow your suggests by now I have another problem.
ifndef MARKERCONTAINE_H
define MARKERCONTAINE_H
include <list>
include <string>
include "Marker.h"
namespace Ableton {
struct DeferencedEqual{
DeferencedEqual(const Marker* compare_to) : compare_to_(compare_to) { }
bool operator()(Marker* c1) const {return *c1 == *compare_to_;}
private:
const Marker* compare_to_;
};
bool compare(Marker* const p1, Marker* const p2){return p1<p2;}
class MarkerContainer {
private:
std::list<Marker*> list;
double end_t;
inline bool exists(std::list<Marker*> *input_list, Marker* check);
// inline int computeInterval(double to_convert, bool beat_t=true);
public:
MarkerContainer();
MarkerContainer(double end_time);
bool addMarker(Marker* input);
double computeBeatTime(double sample_t);
double computeSampleTime(double beat_t);
void printAll();
void sort();
};
}
The function sort is now :
namespace Ableton {
void MarkerContainer::sort(){
list.sort(compare);
}
}
And my main.cpp is :
include "Marker.h"
include "MarkerContainer.h"
include <iostream>
include <list>
include <string>
include <cctype>
using namespace std;
int main (int argc, const char * argv[])
{
Ableton::MarkerContainer::MarkerContainer container = Ableton::MarkerContainer::MarkerContainer(10.0);
Ableton::Marker::Marker* one = new Ableton::Marker::Marker(1.0, 1.0);
Ableton::Marker::Marker* two = new Ableton::Marker::Marker(2.0, 1.0);
Ableton::Marker::Marker* three = new Ableton::Marker::Marker(3.0, 1.0);
if(!container.addMarker(one))
cout << *one << "NOT Added" << endl;
if(!container.addMarker(two))
cout << *two << "NOT Added" << endl;
if(!container.addMarker(three))
cout << *three << "NOT Added" << endl;
cout << "-- LIST " << endl;
container.printAll();
cout << "-- LIST after sort" << endl;
//container.printAll();
}
Now I catch this ld error, it sounds strange for me... no way for me in C++ ? :-)
ld: duplicate symbol Ableton::compare(Ableton::Marker*, Ableton::Marker*) in /..../MarkerContainer.o and /..../main.o for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Command /Developer/usr/bin/clang++ failed with exit code 1
Thanks again in advance, do you can suggest me some book regarding STL and how it works "underground", in order to understand better what happened in these cases technically speacking
pedr0