Ion Ion - 3 months ago 34
C++ Question

Expected initializer before function name

#include <iostream>
#include <string>

using namespace std;

struct sotrudnik {
string name;
string speciality;
string razread;
int zarplata;

sotrudnik create(string n,string spec,string raz,int sal) {
sotrudnik temp;;
return temp;
*sotrudnik str_compare (string str1, string str2, sotrudnik sot1, sotrudnik sot2)

I try to learn C++. But when i try to compile this code with GCC-4.4.5 by using the options " g++ -Wall -c ", I get the following error:

g++ -Wall -c "" (in directory: /home/ion/Univer/Cpp) error: expected initializer before
create error: expected constructor, destructor, or type conversion before

Compilation failed.

Both errors are tied to the function declarations. (round 11 is the declaration of function create, round 20 - of the function
). Tried to google for these kinds of errors, but couldn't find examples of similar errors, as the error messages are very generic. How can I understand their meaning and how to solve them? Thank you very much for your attention.


You are missing a semicolon at the end of your 'struct' definition.



needs to be