Click here to Skip to main content
15,907,687 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Passing string to ATL interface function Pin
Steve S21-Feb-03 1:51
Steve S21-Feb-03 1:51 
QuestionVC6.0 map.insert method is not STL standard? Pin
George220-Feb-03 18:11
George220-Feb-03 18:11 
AnswerRe: VC6.0 map.insert method is not STL standard? Pin
Joaquín M López Muñoz20-Feb-03 20:42
Joaquín M López Muñoz20-Feb-03 20:42 
GeneralRe: VC6.0 map.insert method is not STL standard? Pin
George220-Feb-03 20:50
George220-Feb-03 20:50 
GeneralMy solution is correct? (about funtion parameter in STL) Pin
George220-Feb-03 16:27
George220-Feb-03 16:27 
GeneralRe: My solution is correct? (about funtion parameter in STL) Pin
Christian Graus20-Feb-03 16:52
protectorChristian Graus20-Feb-03 16:52 
GeneralRe: My solution is correct? (about funtion parameter in STL) Pin
George220-Feb-03 17:23
George220-Feb-03 17:23 
GeneralQuestion about overloading operator >> in STL. Pin
George220-Feb-03 3:01
George220-Feb-03 3:01 
Hi, everyone!

I meet with some trouble when debugging the following
codes dealing with overloading operator >> in STL.
I have tried my best to resolve it but still failed.
My IDE is VC6.0.

Source Codes:

--------
#include <iostream>
#include <map>
#include <set>

using namespace std;

class employee_data {
public:
employee_data() : name (""), skill(0), salary(0) {}
employee_data(string n, int s, long sa) :
name (n), skill (s), salary (sa) {}

string name;
int skill;
long salary;

friend ostream& operator<< (ostream& os, const employee_data& e);
};

ostream& operator<< (ostream& os, const employee_data& e) {
os << "employee: " << e.name << " " << e.skill << " " << e.salary;
return os;
}

class employee {
public:
employee (int i, employee_data e) :
identification_code (i), description (e) {}

int identification_code; // key expression to identify an employee
employee_data description;

bool operator< (const employee& e) const {
return identification_code < e.identification_code; }
};

int main()
{
set <employee, less<employee> > employee_set;

multiset <employee, less<employee> > employee_multiset;

employee_data ed1 ("john", 1, 5000);
employee_data ed2 ("tom", 5, 2000);
employee_data ed3 ("mary", 2, 3000);

employee e1 (1010, ed1);
employee e2 (2020, ed2);
employee e3 (3030, ed3);

pair<set <employee, less<employee> >::iterator, bool>
result = employee_set.insert (e1);

if (result.second) cout << "insert ok"; else cout << "not inserted";
cout << endl << (*result.first).description.name << endl;

result = employee_set.insert (e1);
if (result.second) cout << "insert ok"; else cout << "not inserted";

return 1;
}
--------


Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(22) : error C2679: binary '<<' : no operator

defined which takes a right-hand operand of type 'const class std::basic_string<char,struct std::char_traits<char>,class

std::allo
cator<char> >' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(56) : error C2679: binary '<<' : no operator

defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class

std::allocator<
char> >' (or there is no acceptable conversion)
--------

How to resolve them?


Thanks in advance,
George
GeneralRe: Question about overloading operator >> in STL. Pin
Joaquín M López Muñoz20-Feb-03 6:44
Joaquín M López Muñoz20-Feb-03 6:44 
GeneralRe: Question about overloading operator >> in STL. Pin
George220-Feb-03 15:52
George220-Feb-03 15:52 
GeneralNeed a hint on implementing path picker WTL control. Pin
Ilushka20-Feb-03 2:40
Ilushka20-Feb-03 2:40 
GeneralRe: Need a hint on implementing path picker WTL control. Pin
AlexO20-Feb-03 2:51
AlexO20-Feb-03 2:51 
GeneralRe: Need a hint on implementing path picker WTL control. Pin
Ilushka20-Feb-03 4:47
Ilushka20-Feb-03 4:47 
GeneralATL input parameter Pin
Anonymous19-Feb-03 23:54
Anonymous19-Feb-03 23:54 
GeneralRe: ATL input parameter Pin
Steve S20-Feb-03 1:36
Steve S20-Feb-03 1:36 
GeneralMax value in collection (STL) Pin
Kevin McFarlane19-Feb-03 11:19
Kevin McFarlane19-Feb-03 11:19 
GeneralRe: Max value in collection (STL) Pin
Ryan_Roberts19-Feb-03 11:40
Ryan_Roberts19-Feb-03 11:40 
GeneralRe: Max value in collection (STL) Pin
Kevin McFarlane19-Feb-03 11:56
Kevin McFarlane19-Feb-03 11:56 
GeneralStrange behavior - affects performance Pin
Chen Venkataraman19-Feb-03 11:18
Chen Venkataraman19-Feb-03 11:18 
Generalvector.erase(iterator) Pin
Anonymous19-Feb-03 6:20
Anonymous19-Feb-03 6:20 
GeneralRe: vector.erase(iterator) Pin
Joaquín M López Muñoz19-Feb-03 9:08
Joaquín M López Muñoz19-Feb-03 9:08 
GeneralQuestion about strange declaration of STL map. Pin
George219-Feb-03 2:57
George219-Feb-03 2:57 
GeneralRe: Question about strange declaration of STL map. Pin
Joaquín M López Muñoz19-Feb-03 9:04
Joaquín M López Muñoz19-Feb-03 9:04 
GeneralRe: Question about strange declaration of STL map. Pin
George219-Feb-03 19:47
George219-Feb-03 19:47 
GeneralQuick question on CAtlArray Pin
Steve Thresher19-Feb-03 2:45
Steve Thresher19-Feb-03 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.