我有一个结构。
struct studentRec
{
string name;
int sid;
string major;
int cohort;
};
然后,我有一个功能。
int compare_MajorName(const studentRec& s1, const studentRec& s2)
我可以这样调用函数吗?
String major = ECE;
list = new studentRec[n];
compare_MajorName(list[mid], major)
答案 0 :(得分:0)
不,你不能。
您的函数参数需要studentRec
s。 String
无法自动转换为studentRec
。没道理。
您有两种可能性:
String
作为第二个参数String
进行比较:
list[mid].name == major
例如