'Error 3 error C2226: syntax error : unexpected type 'my_profile'
Problem
The following is part of the code snippet for my program:
Code
computer_entry:
{
system("cls");
system("color 4F");
char m2;
cout << "Profile: " << ob1.username << "\n\n" << "COMPUTER ENTRY: \n";
cout << "\n1. Add new computer\n2. Show computer\n3. Update Record\n4. Delete Record\n5. Back\n";
cin >> m2;
switch (m2)
{
case '1':
{
ob5.add_new_computer();
goto computer_entry;
break;
}
case '2':
{
ob5.show_computer();
goto computer_entry;
break;
}
case '3':
{
ob5.update();
goto computer_entry;
break;
}
case '4':
{
ob5.del();
goto computer_entry;
break;
}
case '5':
{
goto master_entry;
break;
}
default:
{
goto computer_entry;
break;
}
}
}
if (ob5.trigger_computer_entry == 1)
{
ob5.trigger_computer_entry = 0;
goto computer_entry;
}
my_profile:
{
system("cls");
system("color 01");
cout << "Profile: " << ob1.username << "\n\n" << "MY PROFILE: \n";
ob9.my_pro_file = ob1.my_file;
ob9.my_profile_details();
_getch();
goto B;
}
change_password:
{
system("cls");
system("color 02");
cout << "Profile: " << ob1.username << "\n\n" << "CHANGE PASSWORD: \n";
ob10.change_user = ob1.change_pass;
ob10.change_passcode();
if (ob10.trigger_A == 1)
{
ob10.trigger_A = 0;
goto A;
}
else if (ob10.trigger_B == 1)
{
ob10.trigger_B = 0;
goto B;
}
}
The full code is found on this github repo: [Cyber-Cafe-management-IS-C ++-program](https://github.com/nk484/Cyber-Cafe-management-IS-program)
Error Message
When one tries to build it up, it generates 16 similar errors as follows:
Error 3 error C2226: syntax error : unexpected type 'my_profile'
for the following:
- my_profile
- member_entry
- computer_entry
- change_password
Any help on how to solve and remove this error since there is no enough documentation on how to solve it in Microsoft Docs as found here: Microsoft C2226 error Documentation.
I tried to check and use the help shown here: Stack overflow but it didn't work.
Solution 1:[1]
Solution
I have just solved it by removing the ambiguity of the names. I differentiated between the class names and those referred by the goto statement. This is shown below:
my_profile1:
{
system("cls");
system("color 01");
cout << "Profile: " << ob1.username << "\n\n" << "MY PROFILE: \n";
ob9.my_pro_file = ob1.my_file;
ob9.my_profile_details();
_getch();
goto B;
}
While the ones in the class remained the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nelson Karanja |
