-1

Visual C++ 2010 で複数の関数を使用して dll を作成しようとしていますが、文字列の使用に関連する構文エラーが発生し続けます。

1>c:\users\new\documents\visual studio 2010\projects\getint\getint\getint.h(9): error C2061: syntax error : identifier 'string'

コードは以下で見ることができます。私は文字通り、前回行ったことに従いました。私が作成した最後のdllには1つの関数があり、ブール値または文字列値はありませんでした.

#include <string>

class getInt
{
public:
    //NB :: static __declspec(dllexport) is need to export data from the dll!

    //This declares the function for retrieving an integer value from the user
    static __declspec(dllexport) int toInt (const string &inStr);
    static __declspec(dllexport) int getNum();
    static __declspec(dllexport) bool isValidInt (const string& str);
};

他にもいくつかの構文エラーがありますが、文字列が他の関数の前にあるために発生していると思います。

4

2 に答える 2

1

stringグローバル スコープにはクラスはなく、std名前空間にあるクラスだけです。したがって、std::string代わりに s を受け入れるように関数を変更します。

#include <string>

class getInt
{
public:
    //NB :: static __declspec(dllexport) is need to export data from the dll!

    //This declares the function for retrieving an integer value from the user
    static __declspec(dllexport) int toInt (const std::string &inStr);
    static __declspec(dllexport) int getNum();
    static __declspec(dllexport) bool isValidInt (const std::string& str);
};
于 2013-09-13T19:06:35.557 に答える
1

stringstd名前空間にあるため、プレフィックスをstd::

#include <string>

class getInt
{
public:
    //NB :: static __declspec(dllexport) is need to export data from the dll!

    //This declares the function for retrieving an integer value from the user
    static __declspec(dllexport) int toInt (const std::string &inStr);
    static __declspec(dllexport) int getNum();
    static __declspec(dllexport) bool isValidInt (const std::string& str);
};
于 2013-09-13T19:07:52.803 に答える