How to get inheritance with argument?

Hi,

So i'm trying to get a function called void MovieList::printTitle(string title) to be used in another class file, but when it comes to arguments it doesnt seem to work.

This is the function in MovieList.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void MovieList::printTitle(string title)
{
    vector<Film>::iterator it;

    for (it = list.begin(); it != list.end(); it++)
    {

        if (it->getTitle() == title)
        {
            it->put();
            cout << endl;
        }
    }
}


And i want to use it in usb.cpp inside a case where i have written
1
2
3
MovieList list;
list.load();
list.printTitle(title);


but it gives me a error saying title was not declared.
So you haven't declared or initialised title in usb.cpp. Do you realise this is not the same as the private title as in the class Film?

In usb.cpp, can you call list.printTitle with a literal string? Or initialise title with a literal string.

HTH
Topic archived. No new replies allowed.