Решено: ВОПРОС Не актуальный. Не знаю, как удалить вопрос.
Ошибка выдается при вызове run в main
#include <iostream>
#include <string>
#include <stdio.h>//to delete
using namespace std;
/*
* The director of film
*/
struct Director
{
string name;
};
/*
* The struct describes the film.
* Each film has:
* a title
* a director
* a ranking
* a price
*/
struct Film
{
string title;
string genre;
Director* director;
double ranking;
double price;
} ;
Film *searchFilmByTitle(Film*, string, int);
Film *searchFilmByGenre(Film*, string, int);
Film *mostpapularFilmByGenre(Film*, string, int);
void print(Film* film, int n);
int main()
{
Director dir1 = {"ABC"}, dir2 = {"BBC"};
Film f1 = {"Film 1","Genre 1", &dir1, 4.2, 890} ,f2 = {"Film 2","Genre 2", &dir2, 4.2, 890} ;
Film *film = new Film[2];
film[0] = f1;
film[1] = f2;
Film* (*run)(Film*, string, int);
Film *d = NULL;
d = run(film, "ABC", 2);
cout << d->title << endl;
return 0;
}
Film *searchFilmByTitle(Film* film, string title, int n)
{
Film *f = NULL;
for (int i = 0; i < n; i++)
{
if (film[i].title.compare(title))
{
f = &film[i];
break;
}
}
return f;
}
void print(Film *film, int n)
{
for (int i = 0; i < n; i++)
{
cout << film[i].title << " " << film[i].director->name<< " " << film[i].price << endl;
}
}