小编Gab*_*l.R的帖子

C++ 11未定义的函数引用

我无法找到解决问题的方法,我认为它与重载函数有关,但我似乎无法弄清楚如何解决它.

这是我的function.cpp

#include "CountLetter.h"
int Countletter(string sentence, char letter) {
    int size = sentence.length();
    int toReturn = 0;

    for (int i = 0; i<= size; ++i) {
            if (sentence[i] == letter) {
                    toReturn++;
            }
    }
    return toReturn;
}
Run Code Online (Sandbox Code Playgroud)

这是我的function.h

#ifndef FN_H
#define FN_H
#include <iostream>

using namespace std;
int CountLetter(string sentence, char letter);

#endif
Run Code Online (Sandbox Code Playgroud)

我的main.cpp

#include "CountLetter.h"

int main() {
    string sent = "";
    char let = ' ';
    int times = 0;

    cout << "Enter a sentence.\n";
    getline(cin, sent); …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors function c++11

0
推荐指数
1
解决办法
826
查看次数

标签 统计

c++ ×1

c++11 ×1

compiler-errors ×1

function ×1