Click here to Skip to main content
15,914,209 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Question about ambiguous overloading operator >> in STL. Pin
George220-Feb-03 23:14
George220-Feb-03 23:14 
GeneralRe: Question about ambiguous overloading operator >> in STL. Pin
Tim Smith21-Feb-03 2:23
Tim Smith21-Feb-03 2:23 
GeneralRe: Question about ambiguous overloading operator >> in STL. Pin
George221-Feb-03 2:42
George221-Feb-03 2:42 
GeneralRe: Question about ambiguous overloading operator >> in STL. Pin
Joaquín M López Muñoz21-Feb-03 2:55
Joaquín M López Muñoz21-Feb-03 2:55 
GeneralRe: Question about ambiguous overloading operator >> in STL. Pin
George221-Feb-03 3:08
George221-Feb-03 3:08 
GeneralPassing string to ATL interface function Pin
Shah Shehpori20-Feb-03 19:52
sussShah Shehpori20-Feb-03 19:52 
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 
Hi, everyone!

Please look at the following source codes, I compile them
in VC6.0. I have tried map.insert(make_pair(...)) works OK.
But map.insert(interator, interator) is not working perperly.
How to resolve the trouble?

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

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()
{

map <int, employee_data, less<int> > employee_map;

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<int, employee_data> a[2] = { make_pair (2020, ed2),
make_pair (3030, ed3) };
employee_map.insert (&a[0], &a[2]);

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


Errors:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(75) : error C2664: 'class std::_Tree<int,struct

std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class

std::allocator<cl
ass employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator __thiscall

std::map<int,class employee_data,struct std::less<int>,class std::allocator<class employee_data> >::insert(class

std::_Tree<int,struct
std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class

std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator,const

struct std::p
air<int const ,class employee_data> &)' : cannot convert parameter 1 from 'struct std::pair<int,class employee_data> *' to

'class std::_Tree<int,struct std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct

std::les
s<int>,class std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data>

>::iterator'
No constructor could take the source type, or constructor overload resolution was ambiguous
--------



Thanks in advance,
George
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 
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 

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.