Hi, I'm having this problem with passing arguments to functions.
You don't need to give me the code , just say what did I did wrong and maybe an example of how the thing goes.
The compiler alerts me that there is one error.
Here's the code:
Code:
#include<iostream>
#include<string>
using namespace std;
class User{
public:
string k_Name;
int k_Free;
};
void Start_Meni(User *array[]);
void Creation(User *array[]);
int Free_Acc_Chk(User *array[]);
int main(){
User *p_array = new User[3];
p_array[0]->k_Free = 1; //I can't initialise in the class itself..?
Start_Meni(p_array);
system("pause");
return 0;
}
void Start_Meni(User p_array){
int opc;
do{
cout<<"(1) Create account"<<endl;
cout<<"(2) Account deleting"<<endl;
cout<<"(3) Account access"<<endl;
cout<<">> ";
cin>>opc;
switch(opc){
case 1:
Creation(p_array);
break;
case 2:
cout<<"Deleting account..."<<endl;
break;
case 3:
cout<<"Accessing account..."<<endl;
break;
default:
cout<<"Non-existing option..."<<endl;
}
}while(opc!=0);
}
void Creation(User p_array[]){
int op = 1,poz;
string name;
if(Free_Acc_Chk(p_array)!= 6){
poz = Free_Acc_Chk(p_array);
cout<<endl;
do{
cout<<"Enter Your name: ";
cin>>name;
cout<<endl;
for(int j=0;j<5;j++){
if(p_array[j]->k_Name == name){
cout<<"You must change the name!"<<endl;
op = 0;
}
}
}while(op=0);
p_array[poz]->k_Name = name;
p_array[poz]->k_Free = 0;
cout<<"New account succesfully opened!"<<endl;
}
else cout<<"Sorry, no more free accounts..."<<endl;
}
int Free_Acc_Chk(User array[]){
for(int x=0;x<5;x++){
if(p_array[x].k_Free != 0){
return x;
}
else return 6;
}
}
Now this is the simplified version of real thing but the problem is same.
I'm doing some mistake about functions arguments and passing.
Please explain this to me.
P.S. Sorry for bad english!