簡體   English   中英

C ++編譯器無法識別成員函數和類型

[英]C++ compiler won't recognize a member function and a type

今天是奇怪的日子。。。有一個愚蠢的hpp文件和另一個愚蠢的cpp文件試圖實現一個愚蠢的類。 他們來了:

// HPP

#ifndef _WFQUEUE_MANAGER_PROXY_HPP_
#define _WFQUEUE_MANAGER_PROXY_HPP_

#include <iostream>
#include <string>

#include "workflow.hpp"
#include "wfqueue.hpp"

//-----------------------------------------------------------------------------
// Enum, struct, aliases
namespace middleware {
typedef struct {
    std::string proxy_ipaddr; /* IP address to manager */
    std::string proxy_port; /* Port to manager */
} WFProxyConfig;
}
//-----------------------------------------------------------------------------
// Class definitions
namespace middleware {
/*!
 * This class provides network interface to access the workflow queue. It is
 * important to notice that constructor is private in order to let a factory
 * perform such a work.
 */
class WFQueueManagerProxy : public WFQueue {
    /*!
     * To let factory build properly this object, we provide access to every
     * part of it.
     */
    friend class WFQueueProxyFactory;
private:
    /*!
     * Privately constructs the object. Default configuration with loopback
     * address and invalid port.
     */
    WFQueueManagerProxy();
public:
    /*!
     * Destructor
     */
    ~WFQueueManagerProxy();
    /*!
     * Enqueues a workflow.
     */
    void enqueue(const Workflow& workflow);
    /*!
     * Dequeues a workflow.
     */
    const Workflow& dequeue();
private:
    /*!
     * Privately constructs the object. Assigning configuration.
     */
    void ConfigureProxy(WFProxyConfig conf);
    /*!
     * Parameters for proxy.
     */
    WFProxyConfig _config;
}; /* WFQueueManagerProxy */
} /* middleware */

#endif

這里另一個

// CPP

#include "wfqueue_manager_proxy.hpp"

using namespace middleware;

//-----------------------------------------------------------------------------
// Constructors and destructor
/* Private constructor */
WFQueueManagerProxy::WFQueueManagerProxy() {
    (this->_config).proxy_ipaddr = "127.0.0.1";
    (this->_config).proxy_port = "0";
}
/* Destructor */
WFQueueManagerProxy::~WFQueueManagerProxy() {

}
//-----------------------------------------------------------------------------
// Public members
/* Enqueue */
void WFQueueManagerProxy::enqueue(const Workflow& workflow) {

}
/* Dequeue */
const Workflow& WFQueueManagerProxy::dequeue() {

}
//-----------------------------------------------------------------------------
// Private members
void WFQueueManagerProxy::ConfigureProxy(WFProxyConfig conf) {

}

有人請向我解釋為什么g ++告訴我這一點:

wfqueue_manager_proxy.cpp:在構造函數'middleware :: WFQueueManagerProxy :: WFQueueManagerProxy()'中:wfqueue_manager_proxy.cpp:32:錯誤:'class middleware :: WFQueueManagerProxy'沒有名為'_config'的成員wfqueue_manager_proxy.cpp:33:錯誤:'class middleware :: WFQueueManagerProxy'沒有名為'_config'的成員wfqueue_manager_proxy.cpp:在全局范圍內:wfqueue_manager_proxy.cpp:51:錯誤:變量或字段'ConfigureProxy'聲明為無效wfqueue_manager_proxy.cpp:51:錯誤:未聲明'WFProxyConfig'在這個范圍內

ABSURD ...它不能識別typedef,也不能識別私有成員...,而且比所有其他功能還要多...為什么g ++無法識別試圖將其視為變量的成員函數? ????

我已經嘗試了所有方法... PS(向誰看了我以前的文章):我的虛擬機現在不是原因。 我檢查並確認沒有虛擬硬盤損壞或與其他虛擬內存單元發生沖突。

只是一個猜測。 不是嗎

WFQueueManagerProxy::WFQueueManagerProxy() { 
    (this->_config).proxy_ipaddr = "127.0.0.1"; 
    (this->_config).proxy_port = "0"; 
} 

當我刪除WFProxyConfig的聲明(或更改聲明的名稱)時,出現了您遇到的錯誤。 您確定張貼了導致錯誤的確切代碼嗎?

帶有前划線的標識符是保留的(包括后衛和_config )。 我有點驚訝,如果其中一個是你的問題-但並不感到驚訝。

_config甚至可以是g ++擴展關鍵字。

好的,這是錯誤。...我也編譯了標頭..如此創建了許多gch .... g ++不會更新那些預編譯的標頭並得到了舊代碼...這就是為什么它對我的任何更改都無動於衷做了...抱歉打擾你們...非常感謝您的幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM