Linker Error

Hello
May someone help
i am a c++ beginner, there is this code that i was trying to do and I seem not to find where can i correct the error

here is the code

#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>

using namespace std;


int main()
{
void admin();
void manager();
void sales();
void display();

char i,username[50],password[50];
cout<<"enter the username\n"
<<"enter the password\n";
cin>>username[i];
cin>>password[i];
if(username=="administration" && password=="admin")
{
//An administrator is responsible for registering the users
admin();
{
int n;

cout<<"enter the number of users";
cin>>n;
for(i=0;i<=n;i++)
cout<<"enter the username & password";
cin>>username;
cin>>password;
}
}
if(username=="manager" && password=="manager")
{
// Managers are responsible for monitoring stock levels and sales
manager();
{
display();
{
cout<<"sales for a particular day is:"<<s;
}
}
if(username=="sales assistants" && password=="sales")
{
// Sales Assistants are responsible for capturing sales
sales();
{
int br,qty;
cout<<"enter the no. of sales";
cin>>s;
cout<<"enter the barcodes of each item";
cin>>br;
cout<<"enter the quantity of items";
cin>>qty;
}
}
system("pause");
return 0;
}
}

here are the errors
[Linker error] undefined reference to `manager()'
[Linker error] undefined reference to `display()'
[Linker error] undefined reference to `sales()'
You cannot implement a function inside a function.

It must be:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>

using namespace std;

void admin();

int main()
{
...
}
admin()
{
int n;

cout<<"enter the number of users";
cin>>n;
for(i=0;i<=n;i++)
cout<<"enter the username & password";
cin>>username;
cin>>password;
}


Accidentally what you wrote is legal, but not what you intended
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
if(username=="administration" && password=="admin")
{
//An administrator is responsible for registering the users
admin(); // This calls admin();
{ // The following is part of main()
int n;

cout<<"enter the number of users";
cin>>n;
for(i=0;i<=n;i++)
cout<<"enter the username & password";
cin>>username;
cin>>password;
}
}
...
Topic archived. No new replies allowed.