Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 无法识别函数调用_C++ - Fatal编程技术网

C++ 无法识别函数调用

C++ 无法识别函数调用,c++,C++,我正在为一项作业写一个魔法八球程序。我所有的函数调用都能工作,只有一个除外。我一直收到一个错误,说没有匹配的函数调用。打电话时使用了原型的副本,所以我知道这不是打字错误。我不明白为什么,因为我觉得它的设置是正确的 main.cpp: int main() { const int MAXSIZE = 100; int size; string responses[MAXSIZE]; string categories[MAXSIZE]; srand(tim

我正在为一项作业写一个魔法八球程序。我所有的函数调用都能工作,只有一个除外。我一直收到一个错误,说没有匹配的函数调用。打电话时使用了原型的副本,所以我知道这不是打字错误。我不明白为什么,因为我觉得它的设置是正确的

main.cpp:

int main() {

    const int MAXSIZE = 100;
    int size;
    string responses[MAXSIZE];
    string categories[MAXSIZE];
    srand(time(0));

    start:
    cout << "A. Read responses/categories from file" << endl;
    cout << "B. Play Magic Eight Ball" << endl;
    cout << "C. Sort by responses" << endl;
    cout << "D. Sort by categories" << endl;
    cout << "E. Write responses/categories to a file" << endl;
    cin >> input;
    ifstream infile;
    ofstream outfile;

    switch (input) {
        case ('A'):
        case ('a'):

            readResponses(infile, responses, categories , MAXSIZE, size);
            break;
    ...
intmain(){
常数int MAXSIZE=100;
整数大小;
字符串响应[MAXSIZE];
字符串类别[MAXSIZE];
srand(时间(0));
开始:

cout在函数
readResponses
中,您声明了
string categories
,并使用
string categories[]
在您的定义中

我不断收到一个错误,说没有匹配的函数可调用。请编辑您的问题并添加错误消息的确切文本。如果这是Visual Studio,则从“输出”选项卡复制该错误,其格式比错误列表的格式更好。在
类别中
是一个数组,在
readRespon中ses
类别
是一个字符串为什么要使用
开始:
标签?在大多数(90%+)程序中,不需要标签。
#include <iostream>     
#include <string>      
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

#ifndef UNTITLED_FUNCTIONS_H
#define UNTITLED_FUNCTIONS_H

void readResponses(ifstream &infile, string responses[], string categories ,const int MAXSIZE, int &size );

#endif //UNTITLED_FUNCTIONS_H
#include <iostream>     
#include <string>      
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include "functions.h"
using namespace std;



void readResponses(ifstream &infile, string responses[], string 
    categories[], const int MAXSIZE, int &size ) {

    string s;
    int num = 0;
    infile.open("magic.txt");

    size = 0;
    while (getline(infile,s) && (num < MAXSIZE)) {

        responses[num] = s;
        getline(infile, s);
        categories[num] = s;
        num++;
    }
    size = num;

    infile.close();

}