Ask not working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
My code seems pretty solid. I don't understand how to call ask for some reason.

template <typename T>
void ask() {
        string choice;
        string parameter;
        T target;
        int exitcheck = 0;
        list * question = new list();
        list * answer = new list();
        question = read();
        answer = question;
        while (exitcheck == 0) {
                cout << "What would you like to search for? (options are: fname, lname, ssn, dob, title, address, town, state, zip, exit, print, clear, save)\n";
                cin >> choice;
                if (choice != "exit" && choice != "print" && choice != "clear" && choice != "save") {
                        cout << "What paramater would you like to work with? (options are: equal, begin)\n";
                        cin >> parameter;
                        cout << "Please state your target\n";
                        cin >> target;
                        answer = search(answer, choice, parameter, target);
                } else if (choice == "exit") {
                        exitcheck = 1;
                } else if (choice == "print") {
                        answer->print();
                } else if (choice == "clear") {
                        answer = question;
                } else if (choice == "save") {
                        ofstream fout; 
                        fout  << "answer.txt";
                }
        }
}

void main () {
        ask();
} 


I get the error:

lab7part1.cpp:302: error: no matching function for call to `ask()'
Since ask is a templated function and takes no parameter, you must explicitly state the data type as template parameter in angled brackets.
So: ask<int>();
In this case i pass T as an int.
Also void is not the return type for main. Must be int, standard C++.

Aceix.
If the user picks fname or lname, etc. I need to have it to be a string. My professor did something clever with this whereby it would automatically take the type of whatever worked. Is that not possible?
Topic archived. No new replies allowed.