jscott
jscott

Reputation: 407

Win32 program compiler errors in class definition file

I am trying to Compile in Visual C++ and just added this config file loader/parser to my project. For some ever function defined in class CProfileData is receiving at least one of two errors:

missing type specifier - int assumed.
syntax error : missing ',' before '&'

When obviously this should just be a referenced string

#ifdef UVSS_EXPORTS
#define UVSS_API __declspec(dllexport)
#else
#define UVSS_API __declspec(dllimport)
#endif


class CProfileData
{

public:
    UVSS_API CProfileData(){};
    UVSS_API CProfileData(const string& profileFile);
    UVSS_API ~CProfileData(void);

    UVSS_API bool GetVariable( const string& sectionName, const string& variableName, string& valueRet );
    UVSS_API bool GetSection( const string& sectionName, SECTION_MAP **pMapRet );
    UVSS_API bool GetVariableW( const string& sectionName, const string& variableName, wstring& valueRet );
    UVSS_API bool GetVariableInt( const string& sectionName, const string& variableName, int *pIntRet );

private:
    void ToLower( string& str );
    void TrimWhitespace( string& str);   
    bool IsComment( const string& str );
    bool IsSection( const string& str, string& secName );
    bool IsVariable( const string& str, string& name, string& value );

    PROFILE_MAP         m_mapProfile;

};

Upvotes: 0

Views: 129

Answers (2)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361772

Include <string>:

#include <string>

And write std::string wherever you've written string.

Its not a good idea to do either of the following in a header file:

using namespace std; //avoid doing this
using std::string;   //avoid doing this as well

Upvotes: 6

Robᵩ
Robᵩ

Reputation: 168876

Ensure that these two lines appear before including this header:

#include <string>
using std::string;

Upvotes: 3

Related Questions