Reputation: 423
#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;
temp.name=n;
temp.speciality=spec;
temp.razread=raz;
temp.zarplata=sal;
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 "lab2.cc" (in directory: /home/ion/Univer/Cpp)
lab2.cc:11: error: expected initializer before
create
lab2.cc:20: error: expected constructor, destructor, or type conversion beforestr_compare
Compilation failed.
Both errors are tied to the function declarations. (round 11 is the declaration of function create, round 20 - of the function str_compare
). 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.
Upvotes: 18
Views: 155006
Reputation: 73
Try adding a semi colon to the end of your structure:
struct sotrudnik {
string name;
string speciality;
string razread;
int zarplata;
} //Semi colon here
Upvotes: 5
Reputation: 100153
You are missing a semicolon at the end of your 'struct' definition.
Also,
*sotrudnik
needs to be
sotrudnik*
Upvotes: 45