尝试编写cin.getline函数,它会抛出一个错误,说没有重载函数的实例?我确定我正确使用参数,不知道如何解决..
#include <iostream>
#include <string>
#include <ctime>
#include <string>
#include <cstring>
#include "NonPerishable.h"
#include "Item.h"
using namespace std;
namespace sict {
class NonPerishable : public Item{
fstream& save(std::fstream& file) const {
file << "N," << sku() << "," << name() << "," << cost() << "," << taxed() << "," << quantity() << endl;
return file;
}
fstream& load(std::fstream& file) {
char sku1[15];
cin.ignore(2);
cin.getline(sku1, 15, ',');
//edit:
double integer;
cin.getline(integer, 15, ',');
}
ostream& write(std::ostream& os, bool linear) const {
}
istream& read(std::istream& is) {
}
fstream& save(std::fstream& file){
}
};
}
任何帮助将不胜感激!
编辑:我修复它以检索字符,但是双打/ int不起作用?
答案 0 :(得分:0)
第三个参数应该是一个char,所以试试单引号:
cin.getline(sku1, 15, ',');