Hi,
New to c++ and have an error that I cannot resolve. Thinking I've just made a very basic mistake and cannot see it.
The error is "prototype for 'void Menu::newItem(std::string, std::string, int)' does not match any in class 'Menu'"
I am certain they match, all similar stack overflow questions were trying to pass too many variables or had different return types which is why this seems so strange.
menu.h
Code:
#ifndef MENU_H
#define MENU_H
#include <string>
using std::string;
#include <iostream>
#include "item.h"
//#define MAXLEN 20
class Menu {
private:
string _fName;
string _mName;
Item _db[20];
int _nElems;
public:
Menu(string mName) : _fName(""), _mName(mName), _nElems(0) { };
void newItem(string category, string description, int price);
void display();
};
#endif
menu.cpp
Code:
#include "menu.h"
#include <string>
using std::string;
#include <iostream>
using std::cout;
using std::endl;
void Menu::newItem(string category, string description, int price){
_db[_nElems] = Item(category, description, price);
_nElems++;
}
void Menu::display(){
string div =
"+--+-------+---------------------------------+-----+\n";
cout << div <<
"|No|Cat. |Description |Price|\n" << div;
for(int i = 0; i < _nElems; i++) {
_db[i].display(i);
}
cout << div;
}
Any help would be greatly appreciated!