簡體   English   中英

創建C ++ CLR托管DLL

[英]Creating C++ CLR Managed DLL

我有這門課:

public ref class Database
    {
    private:
        String ^username, ^password, ^name, ^telNum, ^celNum, ^address, ^location;
        String ^tempUser;
    public:
        Database(String^, String^, String^, String^, String^, String^, String^);
        bool ifFileExists();
        bool ifAccountExists();
        void CreateAccount();
    };

我定義了這個:

bool Database :: ifAccountExists(){ifstream File(“Database.txt”,ios_base :: in);

文件>> tempUser; //此行獲取錯誤我認為String ^存在問題

//返回true或false}

我該如何解決這個問題?

正如Hans指出的那樣,您需要向托管端提供幫助,或者使用托管類型編寫整個代碼,如下所示:

bool Database::IfAccountExists()
{
    if (System::IO::File::Exists(L"Database.txt"))
    {
        array<System::String ^> ^lines = System::IO::File::ReadAllLines(L"Database.txt");
        for each(System::String ^line in lines)
        {
            array<System::String ^> ^tokens = line->Split('|');
            for each (System::String ^token in tokens)
            {
                // if found
                //    return true;
            }
        }
    }

    return false;
}

暫無
暫無

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

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