2013-10-23 56 views
0

我有一個類掃描器,其中的設備消息聲明爲內部像這樣看到。這是scanner.h文件代碼:當在C++中使用內部類時,不允許指向不完整的類類型的指針

#pragma once 
class CScanner 
{ 
public: 
    CScanner(void); 


    class CDeviceMessage; 

    ~CScanner(void); 
}; 

問題發生在設備消息類中,其方法中存在此指針錯誤。它說不完整的類類型的指針不允許CDeviceMessage.h。

的CDeviceMessage.h文件代碼是在這裏,我不包括完整的代碼,但功能界定及和申報,所以你可能明白:

#pragma once 
#include "Scanner.h" 


class CScanner::CDeviceMessage 
{ 

bool MatchesOtherMessage(CScanner::CDeviceMessage * other); 

}; 

並在錯誤出現CDeviceMessage.cpp功能是這樣的:

bool CScanner::CDeviceMessage::MatchesOtherMessage(CDeviceMessage *other) 
{ 

    if (other != NULL) 
      { 
       if ((this->imgMessage != NULL) && (other->imgMessage != NULL))/// here it gives on this pointer error that pointer to incomplete class type is not allowed 
       { 
        int timeDiff = this->imgMessage->OnlineMilliseconds 
          - this->imgMessage->OnlineMilliseconds; 
        if ((timeDiff > -20) && (timeDiff < 40)) 
        { 
         return true; 
        } 
       } 
      } 
      return false; 
} 

回答

0

你缺少在CDeviceMessage *other前面CScanner::前綴

bool CScanner::CDeviceMessage::MatchesOtherMessage(CDeviceMessage *other) 
+0

添加了這個,但問題還沒有解決 –

+0

告訴我另一件事是否有任何問題在這一行它給錯誤:語法錯誤:'常量'和行是: static const int BUFFER_SIZE = 518400 + 400; // here是錯誤 –

+0

那麼,你報告的原始問題解決了嗎?與你的其他錯誤,我看不出你給我的線路有什麼問題,但它看起來像你寫的「常量」而不是「const」。 – Lohrun

相關問題