Card Card::LoadFromFile(char *filename)
{
ifstream file;
int LEN;
file.open(filename, ios::in); // 只读
if (file.fail())
{
cout << "文件不存在." << endl;
file.close();
}
else//文件存在
{
LEN = CountLines(filename);
Card *card = new Card[LEN];
int i = 0;
while (!file.eof()) //读取数据到数组
{
file >> card[i].id >> card[i].money;
i++;
}
return *card;
}
}
一行是一个对象的数据
刚刚开始学c++,马上就要做一个银行管理系统,望指点
PS:这是我第一次提问,不足之处欢迎点出~
CountLines重复定义,造成这个问题的原因可能有
(1)你头文件重复包含了
(2)你写了多个叫做 CountLines 的函数,并且参数类型一致
代码不完整,只能知道这么多。