No matching function

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 10
Reputation: V1RuZ is an unknown quantity at this point 
Solved Threads: 0
V1RuZ V1RuZ is offline Offline
Newbie Poster

No matching function

 
0
  #1
Aug 31st, 2006
Hi

I’m getting compile errors in the following code:

  1. void Driver::read_data()
  2. {
  3. ifstream infile("data", ios::in);
  4. string name, surname;
  5.  
  6. while (infile >> surname) {
  7. infile >> name;
  8. Person temp(infile);
  9. temp.read_surname(infile);
  10. temp.read_name(infile);
  11. temp.read_phone(infile);
  12. temp.read_age(infile);
  13. temp.read_weight(infile);
  14. 87 person_map[surname][name] = temp;
  15. }
  16. }
The errors tell me that

87 driver.cpp instantiated from here
339 stl_map.h no matching function for call to `Person:erson()'

and then it gives me a bunch of candidates. Where am I apparently calling this function?

Here’s what my Person class looks like:

  1. //Person class declaration
  2. class Person {
  3. public:
  4. std::istream& read_surname(std::istream&);
  5. std::istream& read_name(std::istream&);
  6. std::istream& read_phone(std::istream&);
  7. std::istream& read_age(std::istream&);
  8. std::istream& read_weight(std::istream&);
  9. std::string& read_phone(std::string&);
  10. int& read_age(int&);
  11. double& read_weight(double&);
  12. std::string get_name() const { return name; }
  13. std::string get_surname() const { return surname; }
  14. std::string get_phone() const { return phone; }
  15. int get_age() const { return age; }
  16. double get_weight() const { return weight; }
  17. Person(std::string&, std::string&, std::string&, int&, double&);
  18. Person(std::istream&);
  19. private:
  20. std::string surname;
  21. std::string name;
  22. std::string phone;
  23. int age;
  24. double weight;
  25. };
  26. #endif
I’m running Dev C++ on Windows XP(Service Pack 2)

Here’s a short extraction from my compiler log:

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Steven\Desktop\CTI\C++ Unit 3\Finished Project\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Steven\Desktop\CTI\C++ Unit 3\Finished Project\Makefile.win" all
g++.exe -c driver.cpp -o driver.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_map.h: In member function `_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = std::string, _Tp = Person, _Compare = std::less<std::string>, _Alloc = std::allocator<std::pair<const std::string, Person> >]':
driver.cpp:
87: instantiated from here
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_map.h:
339: error: no matching function for call to `Person:erson()'
person_header.h:11: note: candidates are: Person:erson(const Person&)
person_header.h:27: note: Person:erson(std::istream&)
person_header.h:26: note: Person:erson(std::string&, std::string&, std::string&, int&, double&)

Thanx guys
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: No matching function

 
0
  #2
Aug 31st, 2006
Isn'T it obvious?

ifstream infile("data", ios::in);
        string name, surname;
        
        while (infile >> surname) {
            infile >> name;
             Person temp(infile);
Person(std::istream&);
istream and ifstream are not the same.
So the compiler does not know a proper constructor.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 10
Reputation: V1RuZ is an unknown quantity at this point 
Solved Threads: 0
V1RuZ V1RuZ is offline Offline
Newbie Poster

Re: No matching function

 
0
  #3
Aug 31st, 2006
Thanx again WolfPack!

Isn'T it IT?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: No matching function

 
0
  #4
Aug 31st, 2006
huh? Isn't it what?
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC