• Welcome to Valhalla Legends Archive.
 

Ambiguous call problem (fstreams << operators)

Started by warz, March 26, 2006, 04:54 PM

Previous topic - Next topic

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:


database << username << " " << getflags(username) << std::endl;

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


My class looks like this...


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();
}


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?