All were working well until I decided to add a copy constructor.
Please see the program. I am getting
"c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2679: binary '<' : no operator found which
takes a right-hand operand of type 'const D' (or there is no
acceptable conversion)
"
Seems like I can't guarantee constant-ness anymore with the copy
constructor. How do I get around with this ?
// test-sets.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <iostream>
#include <set>
#include <map>
using namespace std;
class D
{
private:
string a;
public:
//Constructor
D()
{
};
//Destructor
~D()
{
};
//Copy constructor
D(D& d)
{
};
std::string& getA()
{
return a;
}
bool operator < (D d) const
{
if(a.compare(d.getA()) <0){
return true;
}else {
return false;
}
}
};
int main()
{
typedef std::set<Ddsets;
D *d = new D();
dsets s;
s.insert(*d);
return 0;
}