new project, new problem

hey guys, got a new problem with a new project. in this project, we split our code into different header files and source files (new to me). i think i've pretty much got it done except now i get 2 errors

here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void SysAdmin::resetPassword(string username, string newPassword) const
{
	string password;
	int failedLogins;

	inStream.open(passwordFile.c_str());
	inStream >> password >> privileges >> failedLogins;
	inStream.close();
	
	if (inStream.fail())
		{
			cerr << "No such user '" << username << "'" << endl;
		}

	ofstream outStream;
	string passwordFile = passwordDir + username + ".txt";
	outStream.open(passwordFile.c_str());
	outStream << newPassword << " " << privileges << " " << 0;
	outStream.close();
}


and the 2 errors are:

Error 1 error C2601: 'SysAdmin::resetPassword' : local function definitions are illegal e:\advancedc++\project 7 (insecurenet)\insecurenet project\sysadmin.cpp 43 InsecureNet Project

and

Error 2 fatal error C1075: end of file found before the left brace '{' at 'e:\advancedc++\project 7 (insecurenet)\insecurenet project\sysadmin.cpp(16)' was matched e:\advancedc++\project 7 (insecurenet)\insecurenet project\sysadmin.cpp 63 InsecureNet Project


anybody have some insight as to what i'm doing wrong here?
You have some unmatched braces somewhere.
Last edited on
well i figured that, this is what showed up when i double clicked the errors, but i don't see any unmatched bracers. i'll double check the rest of the code again
All I can tell you is that the problem is before the code you posted.
ok, got those 2 errors fixed. now i got another error within this block of code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void SysAdmin::resetPassword(string username, string newPassword) const
{
	string password;
	int failedLogins;

	string passwordFile = passwordDir + username + ".txt";
	ifstream inStream;
	inStream.open(passwordFile.c_str());
	inStream >> password >> privileges >> failedLogins;
	inStream.close();
	
	if (inStream.fail())
		{
			cerr << "No such user '" << username << "'" << endl;
		}

	ofstream outStream;
	outStream.open(passwordFile.c_str());
	outStream << newPassword << " " << privileges << " " << 0;
	outStream.close();
}


here is the error:

Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) f:\advancedc++\project 7 (insecurenet)\insecurenet project\sysadmin.cpp 51

that error points to line 9 in the block of code i posted with this. no clue what i did wrong
If you want to modify a member (whatever member you're trying to input into on line 9), the function can't be const.
line 9 is just supposed to read the information in the file being inputted into the stream, it's not changing anything, or isn't supposed to.

lines 17-20 are what changes something in the text file through stream.

if anybody is willing, they can PM me their email address so i can send them the entire project. it does what it's supposed to, until the resetPassword function. it's not running it at all. anybody willing to do this?
Topic archived. No new replies allowed.