No matching function for call to error

I am currently having a compile error that reads:
g++ -c -o assign3.o assign3.cpp
assign3.cpp: In function âint main(int, char**)â:
assign3.cpp:33: error: no matching function for call to âAccountDB::sort_accounts(char*&)â
AccountDB.h:20: note: candidates are: void AccountDB::sort_accounts(char*, int) const
make: *** [assign3.o] Error 1


I am compiling this program through a unix based system using a makefile and nano. I have tried searching through the forums for a helpful hint to help me through this but it just further confuses me. Below is my code to one of my cpp files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "AccountDB.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>

using std::cout;
using std::endl;

int main(int argc, char* argv[])
   {
   AccountDB accountList;

      //argc should be 3 for execution
      if (argc <= 3)
         {
         //passing account file name to read accounts
         accountList.read_accounts(argv[1]);
         //passing transaction file name to process transations
         accountList.process_transactions(argv[2]);

         accountList.sort_accounts(argv[1]);
         accountList.process_transactions(argv[2]);
         accountList.print_accounts();
         }
      else
         {
         cout << "Missing or extra command line argument" <<endl;
         exit(1);
         }
   return 0;
   }


From what I got searching through the forums is that I am referencing something to a const char* which is not the correct data type? Any help would be appreciated.


1) Your program does not have line number 33. However the compiler reported an error in this line. confusing :(
2) I need to look into AccountDB.h as well.
I am sorry about that I have some extra non sense above #include.


g++ -c -o assign3.o assign3.cpp
assign3.cpp: In function âint main(int, char**)â:
assign3.cpp:21: error: no matching function for call to âAccountDB::sort_accounts(char*&)â
AccountDB.h:20: note: candidates are: void AccountDB::sort_accounts(char*, int) const
make: *** [assign3.o] Error 1

Those are the errors. Here is my code for my assign3.cpp file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "AccountDB.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>

using std::cout;
using std::endl;

int main(int argc, char* argv[])
   {
   AccountDB accountList;

      //argc should be 3 for execution
      if (argc <= 3)
         {
         //passing account file name to read accounts
         accountList.read_accounts(argv[1]);
         //passing transaction file name to process transations
         accountList.process_transactions(argv[2]);

         accountList.sort_accounts(argv[1]);
         accountList.process_transactions(argv[2]);
         accountList.print_accounts();
         }
      else
         {
         cout << "Missing or extra command line argument" <<endl;
         exit(1);
         }
   return 0;
   }


This is my accountDB.h header file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef ACCOUNT_LIST_H
#define ACCOUNT_LIST_H

#include "CreditAccount.h"

class AccountDB
   {
   private:

      CreditAccount accountArray[20];
      int numAccounts;

   public:

      AccountDB();
      void read_accounts(char*)const;
      int find_account(char*)const;
      void print_accounts()const;
      void process_transactions(char*)const;
      void sort_accounts(char*, int)const;
   };

#endif 


You need to pass some 'int' value as second parameter for sort_accounts. If second parameter is optional declare function like void sort_accounts(char*, int i = 0)const;. Also you need to handle if 'i' have some default value.
I completely forgot you thank you. I followed your direction and it worked.
Topic archived. No new replies allowed.