Original Post
Hello, I am trying to make a class work in C++. This is what I have written so far,
This gives me a couple of errors when I try to build it,
||=== brugersystem v2, Debug ===|
Line 36 |error: no matching function for call to 'getline(std::string&)'|
Line 59 |error: 'current' is not a class or namespace|
Line 61 |error: 'current' is not a class or namespace|
||=== Build finished: 3 errors, 0 warnings ===|
I am not sure with any of them. The line 59 and 61 errors are given when I want to create a database with a "default" admin member, Line 36 I try to recieve line input from a user. This whole program is to be a sort of vague usersystem. It will check whether the .txt file containing information exists. If not, it should create the database with an default admin account.
Regards,
Boooke
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
struct userstats
{
string ID;
int secLev; // 0, normal user (Costumer, can only interact through messages)
// 1 moderator (Can delete level 0 users and see list of users)
// 2 admin (Same as moderator, but right to delete moderators aswell, defines root password) - INERASABLE
string name;
string password;
};
class userbase
{
private:
string password;
public:
userbase();
static vector<userstats> users;
void setPas();
// void resetdb(string uP);
};
userbase::userbase()
{
password = "default";
}
void userbase::setPas()
{
cout << "Enter current admin/root password: ";
string pass;
getline(pass);
if (pass == userbase::password)
{
password = pass;
userbase::users[1].password = pass;
}
else
cout << "Password incorrect.";
}
int main()
{
userbase current;
ifstream inFile;
inFile.open("userlist.txt");
if(!inFile.good())
{
current::users.push_back();
ofstream outFile("userlist.txt");
outFile << current::users(1).ID;
}
return 0;
}
This gives me a couple of errors when I try to build it,
||=== brugersystem v2, Debug ===|
Line 36 |error: no matching function for call to 'getline(std::string&)'|
Line 59 |error: 'current' is not a class or namespace|
Line 61 |error: 'current' is not a class or namespace|
||=== Build finished: 3 errors, 0 warnings ===|
I am not sure with any of them. The line 59 and 61 errors are given when I want to create a database with a "default" admin member, Line 36 I try to recieve line input from a user. This whole program is to be a sort of vague usersystem. It will check whether the .txt file containing information exists. If not, it should create the database with an default admin account.
Regards,
Boooke