1
我是Visual C++新手。我寫了我的班,但它有錯誤如何在Visual C++ 2010中設置簡單的LinkedList?
錯誤1錯誤C3845:'CRegistration :: list1':只有靜態數據成員可以在ref類或值類型內初始化c:\ users \ marco \ desktop \ cs351 \ hw3 \ project3 \ CRegistration.h 44 1項目3
我明白編譯器已經說過錯誤是什麼。但是,我不明白它的意思。以下是我的代碼
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::Collections::Generic;
public ref class CRegistration
{
public:
CRegistration(void){
ClickBoxRecord = 0;
ClickBoxRecord = 0;
};//end constructor
void SetRadioRecord(int flag){ RadioRecordRecord = flag; }
void SetClickBoxRecord(int flag){ ClickBoxRecord = flag; }
int GetRadioRecordRecord(){return RadioRecordRecord}
int GetClickBoxRecord(){return ClickBoxRecord}
protected:
private:
int RadioRecordRecord;
int ClickBoxRecord;
LinkedList<int> list1 = gcnew LinkedList<int>();
LinkedList<String^> ^list2 = gcnew LinkedList<String^>();
LinkedList<String^> ^list3 = gcnew LinkedList<String^>();
LinkedList<String^> ^list4 = gcnew LinkedList<String^>();
LinkedList<String^> ^list5 = gcnew LinkedList<String^>();
};//end ref class
感謝您的回覆。我的老師提到LinkedList可以存儲任何東西。我怎樣才能讓LinkedList存儲int,doulble和string?謝謝 – Marco 2012-03-06 05:47:10
@Marco根據評論更新。 FWIW如果你打算使用CLI,你可能只需要使用C#。 – AJG85 2012-03-06 16:30:51