I am trying to implement my database, and I'm working on the "addtable" function, but for some reason, the "find" method didn't work(which is my first "if statement" in the code), and I have gotten this error:
" ‘void Database::addTable(std::string, Table)’:
Database.cpp:18:13: error: ‘class std::vector<Table>’ has no member named ‘find’
if (tables.find(name) != tables.end())"
So I modified it, and it still won't work, can anyone help me understand the problem? Thanks.
Code:
#include "Database.h"
#include <iostream>
#include <algorithm>
Database::Database(){
}
Database::Database(vector<Table> tables){
}
void Database::addTable(string name, Table t){
//if (tables.find(name) != tables.end()) --Had this, which gave me the error above.
//So I changed to this:
if (find(tables.begin(), tables.end(), name) != tables.end())
throw InvalidOperation("Table " + name + " is in the database already");
tables[name] = t;
}