【问题标题】:class type redefinition and base class undefined errors类类型重定义和基类未定义错误
【发布时间】:2014-03-04 07:54:55
【问题描述】:

我有以下代码返回以下错误 SFDHelper:'class'类型重新定义--File=sfdhelper.h SFDHelper:基类未定义--sfd_metadatamanager.h

SFDHelper.h:
class SFDHelper
{
protected:

private:

public: 
    SFDHelper();
    ~SFDHelper();
    //FileAction(Create/Modify/Delete) methods
    typedef enum FileAction { faNone, faDelete, faCreate, faChange, } EFileAction;
    #define IS_NOTACT_FILE( action ) ( action == faNone   )
    #define IS_CREATE_FILE( action ) ( action == faCreate )
    #define IS_DELETE_FILE( action ) ( action == faDelete )
    #define IS_CHANGE_FILE( action ) ( action == faChange )

    //Converts CString to String
    std::string convertCStringToString(CString csFile);

    //Split functions 
    std::string split(fs::path strToSplit);
    std::string splitFileName(string strToSplit);
    std::string splitFilePath(fs::path strToSplit);
    std::string splitFileNameFromNameAndSize(fs::path strToSplit);
    std::string splitFileType(string strToSplit);

    //Storage functions 
    void storeInMap(string line,std::map<std::string,std::string> &mymap);
    void storeInMMap(string line,std::multimap<std::string,std::string> &mymmap1,std::multimap<std::string,std::string> &mymmap2);

    //Data retreival functions
    string getFilePathFromFileData(fs::path fileDataRecvd);
    std::string getFileNameFromFileData(fs::path fileDataRecvd);
    string getFileSizeFromFileData(fs::path fileDataRecvd);
    string getFileCRC32FromFileData(fs::path fileDataRecvd);
    int GetCrc32(const string& filePath);

    //File read/write functions 
    void writeDataToFile(string fname, string data, bool append=false);
    string readFileDataInStr(string fname);

    time_int GetTimeMs64();
};

SFDMetadamanager.h:

#include "SFDHelper.h"

class SFD_MetadataManager:public SFDHelper
{

private:


public: 
    SFD_MetadataManager();
    ~SFD_MetadataManager();
    bool isOpenDB;
    bool categoryTableExists;
    bool taggedFileTableExists;
    bool recoveryTableExists;
    std::string mediaScanCompleted;
    std::string appCrashedInPreviousSession;
    bool notYetUpdatedRecoveryTable;

    sqlite3 *dbfile;

    //SqLite functions
    bool ConnectDB ();
    void DisonnectDB ();
    void fireSQLQuery(char* query,vector<vector<string>> &results);
    //void createSQLQuery(EFileAction faAction,std::string filePath);

};

SFD_Metadatamanager 类继承 SFDHelper 类是单继承。 提前感谢您的帮助。

【问题讨论】:

  • 请正确布局您的代码示例,以便我们阅读:)

标签: c++ redefinition


【解决方案1】:

在标题中添加包含防护:

#ifndef SFDHELPER_H
#define SFDHELPER_H

//contents of SFDHelper.h

#endif

其他标题也类似。

【讨论】:

  • SFD_Metadatamanager 继承了 SFDHelper。如果我添加建议的代码,我的 sfdhelper.h 类将变得不可见。
猜你喜欢
  • 1970-01-01
  • 2014-09-03
  • 2023-04-06
  • 1970-01-01
  • 1970-01-01
  • 2016-09-27
  • 2014-11-01
  • 1970-01-01
  • 2016-08-07
相关资源
最近更新 更多