Hello cppnoobie,
In the "insertElement" function of the "functionallity" file I found two problems:
First is the same problem as with the "returnID" function. The "stoi" function is trying to convert the wrong element of the vector. I solved the problem in both functions with
int id1 = std::stoi(args[args.size() - 1]);
based on the last element of the vector being the ID number to put into an "int".
The second problem is
std::string name = join(args, 2);
. I am not sure what the 2 is for, but the returned value is the ID number. So in the next line you are inserting ID as an "int" and ID as a string under the name "name". Later when I chose option 8 from the main menu it printed the ID twice. I do not think that is what you want.
Now for other thing I saw.
In the two header files you use #ifndef statements to include header files like "iostream". This is not the way to do this or the place. Header files like "iostream", "string" and others need to be in the ".cpp" files. In the ".cpp" files after the normal includes you include your header file, i.e., anything that uses double quotes around the file name. This way the above header files will cover what is in your header files.
After all the "#if..."s I saw the line "#pragma once". This should be at the top of the file. The first line to work properly. You can eliminate the need for "#pragma once" with the use of a header guard like:
1 2 3 4 5 6
|
#ifndef __FUNCITIONALLITY_H__
#define __FUNCITIONALLITY_H__
// your code here.
#endif // end !__FUNCITIONALLITY_H__
|
The underscores at the beginning and the end are optional. I think I used something I already had when I created this bit of code.
At the beginning of "main" you have several functions. I would consider putting these in their own ".cpp" file.
I do not mean that you have to change your header files for this program because it does work, but in the future do not put include files like 'iostream" in the header files. Put them in the ".cpp" files where they belong.
Hope that helps,
Andy