I’m trying to call a function within my main in a program in which I am trying to convert from C to C++. All my function calls within other functions compile without error, but when it gets to the one function call in the main I get no matching function for call to contacts::menu(contacts*[5], int*, int&, char[50])'
Here is the main:
int main() {
contacts *friends[5];
char buffer[BUFFSIZE];
int counter=0;
int i=0;
contacts::menu(friends, &counter,i,buffer);
getch();
return 0;
}
here is the class with the function declaration:
class contacts
{
private:
char *First_Name;
char *Last_Name;
char *home;
char *cell;
public:
//constructor
contacts()
{
}
//Function declarations
static void menu(contacts*friends ,int* counter,int i,char buffer[]);
};
Here is the beginning part of the menu function, just so you can get an idea what It was labelled:
void contacts::menu(contacts*friends,int* counter, int i,char buffer[])
{
int user_entry=0;
int user_entry1=0;
int user_entry2=0;
char user_entry3[50]={'\0'};
FILE *read;
printf("Welcome! Would you like to import a file? (1)Yes or (2) No");
scanf("%d",&user_entry1);
if(user_entry1==1)
{
printf("Please enter a file name");
scanf("%s",user_entry3);
read=fopen(user_entry3,"r+");
Like I said, the other functions within my program don’t receive any errors, but this one does. I’m new to C++ so I wasn’t sure if there was something special I needed to add to call a function within the main.
Don’t use pointers
and your code will compile.