-1
我有一个电影类,其中有构造函数需要7个参数像这样;指针阵列的用法
Movie:: Movie(string ttle,string sts ,double prc,int yr,string gnr,Date rls,int id)
我想使用动态内存的电影数组,但它给了错误,我无法找到它
int main() {
int counter=0; // size of array
Movie *moviearray;
moviearray= new Movie[counter];
ifstream filein("DVD_list.txt");
for (string line; getline(filein, line);)
{
counter++;
vector<string> v;
split(line, '\t', v); // v is an vector and puts string words that has splitted based on tab
moviearray[counter] =(v[0],v[1] ,stod(v[2]),stoi(v[3]),v[4],Date(v[5]),stoi(v[6])); // ERROR
如何创建数组中的电影对象?
您正试图使大小为0的数组,因为'计数器= 0' – CoryKramer
我想数组大小和行在txt文件中是相等的 – pflove