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.
#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.
#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;
}
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.