加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 没有在类中声明的成员函数 – 基本编译时出错

发布时间:2020-12-16 10:32:59 所属栏目:百科 来源:网络整理
导读:编译基本类和标题时出现此错误.不确定我是否遗漏了明显的东西?如果需要,可以提供任何其他细节. 注意:我添加了#include string在Event.h中,错误仍然存??在. Event.cpp #include "Event.h"#include stringstd::string Event::getLabel() { return label;} Ev
编译基本类和标题时出现此错误.不确定我是否遗漏了明显的东西?如果需要,可以提供任何其他细节.

注意:我添加了#include< string>在Event.h中,错误仍然存??在.

Event.cpp

#include "Event.h"
#include <string>

std::string Event::getLabel() {
    return label;
}

Event.h

#ifndef EVENT_H
#define EVENT_H

#define EVENT_STOP 0
#define EVENT_START 1


class Event {
private:

protected:
    double time;
    std::string label;
    int type; // EVENT_START OR EVENT_STOP

public:
    std::string getLabel(); 

};

#endif

编译和错误

g++ -c -Wall -pedantic correngine.cpp
g++ -c -Wall -pedantic CSVManager.cpp
g++ -c -Wall -pedantic ServerEvent.cpp 
g++    -c -o UPSEvent.o UPSEvent.cpp
g++ -c -Wall -pedantic CorrelationEngineManager.cpp
g++ -c -Wall -pedantic Event.cpp
Event.cpp:4: error: no ‘std::string Event::getLabel()’ member function declared in class ‘Event’
make: *** [Event.o] Error 1

解决方法

我有一个类似的问题,并通过删除标题旁边生成的[标题名称] .gch文件解决了它,显然已经损坏了.也许你可以尝试一下?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读