简体   繁体   English

C ++:类“ X”没有名为“ Y”的成员

[英]C++: class “X” has no member named “Y”

I have two projects: Project A & Project B . 我有两个项目: Project AProject B。 In Project A, I have the class: 1. 在项目A中,我有课:1。

I've included the class '1' from Project A using "#include '1' & using the configuration in eclipse. 我已经使用“ #include'1'和使用eclipse中的配置来包含来自Project A的类'1'。

When I try to access a public method from class 1 in Project B I'm getting the error: Class "A" has no member named "Test". 当我尝试从项目B中的类1访问公共方法时,出现错误:类“ A”没有名为“ Test”的成员。

What am I doing wrong??? 我究竟做错了什么???

EDIT: The class name & method is for skeleton purposes. 编辑:类名和方法是用于骨架目的。

Project "MGeneral" has a class called "MGeneralCommands" - 项目“ MGeneral”具有一个名为“ MGeneralCommands”的类-

class MGeneralCommands
{
    public:

        void sendCommand(TCPSocket * sock,int command);
        void sendData(TCPSocket * sock,string data);
        int readCommand(TCPSocket * sock);
        string readData(TCPSocket * sock);
};

Project "MSA" has a class called "TCPMessengerServer" in which I've used " #include "MGeneralCommands.h" ". 项目“ MSA”有一个名为“ TCPMessengerServer”的类,其中我使用了“ #include "MGeneralCommands.h" “。 For example, when trying to call the method "sendCommand" it won't recognize it. 例如,当尝试调用方法“ sendCommand”时,它将无法识别它。

From the comments, the error is actually something completely different: 从注释来看,错误实际上是完全不同的:

‘sendData’ was not declared in this scope

from the code 从代码

sendData(socket,"TEST");

Unless you're already in a member function of MGeneralCommands (or a subclass), you'll need an object of that type to call it on: 除非您已经在MGeneralCommands (或子类)的成员函数中, MGeneralCommands将需要该类型的对象来对其进行调用:

commands.sendData(socket,"TEST");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM