Sorry, I'm such a C++ noob. I had no idea a string would be that big of a deal. I'll post my full code like I should have from the start. I've changed some things to fit what you said, but for the most part it is the same.
Code:
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
class UserPw
{
public:
UserPw();
UserPw(string user, string password);
string getUser();
string getPassword();
private:
string user;
string password;
};
UserPw::UserPw()
{
string user="";
string password="";
}
UserPw::UserPw(string user, string password)
{
this->user = user;
this->password = password;
}
string UserPw::getUser()
{
return user;
}
string UserPw::getPassword()
{
return password;
}
class PasswordFile
{
public:
PasswordFile();
PasswordFile(string filename);
vector<UserPw> getFile();
void addpw(UserPw newentry);
private:
string filename;
vector<UserPw> entry;
};
PasswordFile::PasswordFile()
{
vector<UserPw> entry;
string filename = "";
}
PasswordFile::PasswordFile(string filename)
{
this->filename = filename;
UserPw x;
ifstream infile;
infile.open(filename.c_str());
getline(cin, x);
entry.push_back(x);
while(infile.good())
{
getline(cin, x);
entry.push_back(x);
}
}
vector<UserPw> PasswordFile::getFile()
{
return entry;
}
void PasswordFile::addpw(UserPw newentry)
{
ofstream File("password.txt");
entry.push_back(newentry);
for(int i=0;i<entry;i++)
{
File>> entry[i];
}
}
int main()
{
PasswordFile passfile("password.txt");
passfile.addpw(UserPw("dbotting","123qwe"));
passfile.addpw(UserPw("egomez","qwerty"));
passfile.addpw(UserPw("tongyu","liberty"));
}