Ion*_*Ion 12 c++ gcc compilation
#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)
Run Code Online (Sandbox Code Playgroud)
我尝试学习C++.但是当我尝试使用选项"g ++ -Wall -c"使用GCC-4.4.5编译此代码时,我收到以下错误:
g ++ -Wall -c"lab2.cc"(在目录中:/ home/ion/Univer/Cpp)
lab2.cc:11:错误:
create
lab2.cc:20 之前的预期初始化程序:错误:str_compare
编译失败前的预期构造函数,析构函数或类型转换.
这两个错误都与函数声明有关.(第11轮是函数创建的声明,第20轮 - 函数str_compare).试图谷歌这些类型的错误,但无法找到类似错误的例子,因为错误消息非常通用.我怎样才能理解它们的含义以及如何解决它们?非常感谢您的关注.
bma*_*ies 30
您在'struct'定义的末尾缺少分号.
也,
*sotrudnik
Run Code Online (Sandbox Code Playgroud)
需要是
sotrudnik*
Run Code Online (Sandbox Code Playgroud)
尝试在结构末尾添加分号:
struct sotrudnik {
string name;
string speciality;
string razread;
int zarplata;
} //Semi colon here
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
82578 次 |
| 最近记录: |