Valhalla Legends Forums Archive | C/C++ Programming | Ambiguous call problem (fstreams << operators)

AuthorMessageTime
warz
I'm putting a lot of related functions into a class. One function opens a file, using ofstream, and attempts to place data in the file. I'm getting an error though, on this line of code:

[code]
database << username << " " << getflags(username) << std::endl;

c:\Documents and Settings\...\Desktop\Client\AccessManipulation.h(127) : error C2593: 'operator <<' is ambiguous
[/code]

My class looks like this...

[code]
class AccessManipulation {
private:
union UserAttributes { ... };
typedef std::map<std::string, UserAttributes> themap;
themap accessmap;

public:
bool loadDatabase(std::string filename);
void saveDatabase(std::string filename);
};

bool AccessManipulation::loadDatabase(std::string filename) { ... }

void AccessManipulation::saveDatabase(std::string filename) {
std::remove(filename.c_str());
themap::iterator iter = accessmap.begin();

std::ofstream database(filename.c_str());
std::string username;
while(iter != accessmap.end()) {
username = (*iter).first;
database << username << " " << getflags(username) << std::endl;
iter++;
}
database.close();
}
[/code]

I include headers.h, in this accessmanip.h. Headers.h includes iostream, fstream, etc. I had no such problems prior to placing these functions in the class. What's wrong?
March 26, 2006, 10:54 PM
warz
Solved. I'm an idiot.
March 27, 2006, 7:22 AM

Search