C ++尝试使用向量

时间:2013-05-22 01:17:58

标签: c++ object vector structure

我需要使用矢量作为Film对象。向我抛出错误并且不确定需要移动的地方或者我是否错误地命名。可能是显而易见的事情。

代码:

#include "std_lib_facilities.h"

int main() 
{ 

    class Film 
    {
    public:
        Film();
        Film(string sl, string el);

    };

    cout << "Please enter first film:\n";
    string start_film;
    cin >> start_film;
    cout << "\nPlease enter a second film:\n";
    string end_film;
    cin >> end_film;
    cout << "\nPlease enter a date (format = dd/mm/yyyy):\n";
    string date;
    cin >> date;

    string name;
    name = "films.txt";
    ifstream ist(name.c_str());

    if (!ist)
        error("Cannot open output file " + name);

    vector<Film> temps; // create a vector to store the readings
    string film;
    string director;
    float rating;
    int year;
    int date;

    while (ist >> film >> director >> rating >> year >> date) 
    { // read
        // check
        temps.push_back(Film(film,director, rating, year, date)); // store
    }

    cout << "Start: " + start_film + " End: " + end_filmn + " Date: " + date + "\n";

    keep_window_open();
    return 0;
}

非常感谢任何可以指出的结构错误或建议去哪里。

警告:

main :: Flight :: Flight本地类成员函数没有正文 错误:main :: Flight :: Flight:没有重载函数需要5个参数

0 个答案:

没有答案