Problem mit Array aus Objekten Windowsforms



  • Hallo zusammen,

    ich bin dabei ein kleine Anwendung zum Öffnen einer Türe mit Windows Forms zu erstellen.
    Leider habe ich hierbei das Problem, dass ich gerne ein Array aus mehreren Objekten der Klasse "Users" als Attribute der WinForm Klasse erzeugen möchte und das überhaupt nicht klappt (siehe Zeile 96).

    array<Users, 1> ^ar = gcnew array<Users, 1>(NUMBER_OF_USERS);
    

    Der Sinn dieses Arrays sollte es sein die Daten der verschieden Nutzer darin zuspeichern.
    Kann mir da jemand dabei helfen?

    #pragma once
    #include <string>
    #include "Users.h"
    #include <array>
    
    #define MAX_CODE_LENGTH		12			// digits uint64!
    #define MAX_ID_LENGTH		2			// digits uint16!
    #define MAX_USERS			99					
    #define BUFFER_LIFETIME		60000		// ms
    #define UNLOCK_TIME			20000		// ms
    #define CODE				"79331"
    #define MASTER_CODE			"1234567890"
    #define ID					11
    #define NUMBER_OF_USERS		20			// numbers of users
    
    #define TEXT_INPUT_CODE			"Codeeingabe"
    #define TEXT_INPUT_MASTERCODE	"Master-Mode-Abfrage"
    #define TEXT_INPUT_ID			"Nutzerkennungseingabe"
    #define TEXT_CODE_SUCCESS		"Türe wird entriegelt"
    
    namespace DoorLock {
    	using namespace std;
    	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 User;
    
    	/// <summary>
    	/// Summary for MyForm
    	/// </summary>
    	public ref class MyForm : public System::Windows::Forms::Form
    	{
    	public:
    		MyForm(void)
    		{
    			InitializeComponent();
    			bo_door_unlocked = false;
    			bo_door_open = false;
    			bo_id_checked =false;
    			bo_master_mode_request = false;
    			bo_master_mode_en = false;
    			bo_id_checked = false;
    			uint_id_current = 0;
    			str_input_buffer = "";
    		}
    
    	protected:
    		~MyForm()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	private: System::Windows::Forms::Button^  button1;
    	private: System::Windows::Forms::Button^  button2;
    	private: System::Windows::Forms::Button^  button3;
    	private: System::Windows::Forms::Button^  button4;
    	private: System::Windows::Forms::Button^  button5;
    	private: System::Windows::Forms::Button^  button6;
    	private: System::Windows::Forms::Button^  button7;
    	private: System::Windows::Forms::Button^  button8;
    	private: System::Windows::Forms::Button^  button9;
    	private: System::Windows::Forms::Button^  button0;
    
    	private: System::Windows::Forms::Button^  buttonC;
    	private: System::Windows::Forms::Button^  buttonB;
    	private: System::Windows::Forms::Timer^  timerInactive;
    
    	private: System::ComponentModel::IContainer^  components;
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::Label^  label3;
    	private: System::Windows::Forms::Label^  label4;
    	private: System::Windows::Forms::Timer^  timerLock;
    
    	private:
    		bool bo_door_unlocked;
    		bool bo_door_open;
    		bool bo_id_checked;
    		bool bo_master_mode_request;
    		bool bo_master_mode_en;
    		unsigned int uint_id_current;
    
    		String^ str_input_buffer;
    
    		array<Users, 1> ^ar = gcnew array<Users, 1>(NUMBER_OF_USERS);
    
    		bool bo_CheckId();
    		bool bo_CheckCode();
    		bool bo_CheckMasterCode();
    		void ClearBufferScreen();
    		void TimerInactiveReset();
    		void AddDigit(String ^digit);
    		void DoorUnlocking();
    		void DoorLocking();
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->components = (gcnew System::ComponentModel::Container());
    			this->button0 = (gcnew System::Windows::Forms::Button());
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->button2 = (gcnew System::Windows::Forms::Button());
    			this->button3 = (gcnew System::Windows::Forms::Button());
    			this->button4 = (gcnew System::Windows::Forms::Button());
    			this->button5 = (gcnew System::Windows::Forms::Button());
    			this->button6 = (gcnew System::Windows::Forms::Button());
    			this->button7 = (gcnew System::Windows::Forms::Button());
    			this->button8 = (gcnew System::Windows::Forms::Button());
    			this->button9 = (gcnew System::Windows::Forms::Button());
    			this->buttonC = (gcnew System::Windows::Forms::Button());
    			this->buttonB = (gcnew System::Windows::Forms::Button());
    			this->timerInactive = (gcnew System::Windows::Forms::Timer(this->components));
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->label4 = (gcnew System::Windows::Forms::Label());
    			this->timerLock = (gcnew System::Windows::Forms::Timer(this->components));
    			this->SuspendLayout();
    			// 
    			// button0
    			// 
    			this->button0->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button0->Location = System::Drawing::Point(103, 300);
    			this->button0->Name = L"button0";
    			this->button0->Size = System::Drawing::Size(90, 54);
    			this->button0->TabIndex = 9;
    			this->button0->Text = L"0";
    			this->button0->UseVisualStyleBackColor = true;
    			this->button0->Click += gcnew System::EventHandler(this, &MyForm::button0_Click);
    			// 
    			// button1
    			// 
    			this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button1->Location = System::Drawing::Point(7, 120);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(90, 54);
    			this->button1->TabIndex = 0;
    			this->button1->Text = L"1";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
    			// 
    			// button2
    			// 
    			this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button2->Location = System::Drawing::Point(103, 120);
    			this->button2->Name = L"button2";
    			this->button2->Size = System::Drawing::Size(90, 54);
    			this->button2->TabIndex = 1;
    			this->button2->Text = L"2";
    			this->button2->UseVisualStyleBackColor = true;
    			this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
    			// 
    			// button3
    			// 
    			this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button3->Location = System::Drawing::Point(199, 120);
    			this->button3->Name = L"button3";
    			this->button3->Size = System::Drawing::Size(90, 54);
    			this->button3->TabIndex = 2;
    			this->button3->Text = L"3";
    			this->button3->UseVisualStyleBackColor = true;
    			this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
    			// 
    			// button4
    			// 
    			this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button4->Location = System::Drawing::Point(7, 180);
    			this->button4->Name = L"button4";
    			this->button4->Size = System::Drawing::Size(90, 54);
    			this->button4->TabIndex = 4;
    			this->button4->Text = L"4";
    			this->button4->UseVisualStyleBackColor = true;
    			this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
    			// 
    			// button5
    			// 
    			this->button5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button5->Location = System::Drawing::Point(103, 180);
    			this->button5->Name = L"button5";
    			this->button5->Size = System::Drawing::Size(90, 54);
    			this->button5->TabIndex = 3;
    			this->button5->Text = L"5";
    			this->button5->UseVisualStyleBackColor = true;
    			this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
    			// 
    			// button6
    			// 
    			this->button6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button6->Location = System::Drawing::Point(199, 180);
    			this->button6->Name = L"button6";
    			this->button6->Size = System::Drawing::Size(90, 54);
    			this->button6->TabIndex = 5;
    			this->button6->Text = L"6";
    			this->button6->UseVisualStyleBackColor = true;
    			this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
    			// 
    			// button7
    			// 
    			this->button7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button7->Location = System::Drawing::Point(9, 240);
    			this->button7->Name = L"button7";
    			this->button7->Size = System::Drawing::Size(90, 54);
    			this->button7->TabIndex = 8;
    			this->button7->Text = L"7";
    			this->button7->UseVisualStyleBackColor = true;
    			this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
    			// 
    			// button8
    			// 
    			this->button8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button8->Location = System::Drawing::Point(103, 240);
    			this->button8->Name = L"button8";
    			this->button8->Size = System::Drawing::Size(90, 54);
    			this->button8->TabIndex = 7;
    			this->button8->Text = L"8";
    			this->button8->UseVisualStyleBackColor = true;
    			this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
    			// 
    			// button9
    			// 
    			this->button9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->button9->Location = System::Drawing::Point(199, 240);
    			this->button9->Name = L"button9";
    			this->button9->Size = System::Drawing::Size(90, 54);
    			this->button9->TabIndex = 6;
    			this->button9->Text = L"9";
    			this->button9->UseVisualStyleBackColor = true;
    			this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
    			// 
    			// buttonC
    			// 
    			this->buttonC->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->buttonC->Location = System::Drawing::Point(9, 300);
    			this->buttonC->Name = L"buttonC";
    			this->buttonC->Size = System::Drawing::Size(90, 54);
    			this->buttonC->TabIndex = 10;
    			this->buttonC->Text = L"C";
    			this->buttonC->UseVisualStyleBackColor = true;
    			this->buttonC->Click += gcnew System::EventHandler(this, &MyForm::buttonC_Click);
    			// 
    			// buttonB
    			// 
    			this->buttonB->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->buttonB->Location = System::Drawing::Point(199, 300);
    			this->buttonB->Name = L"buttonB";
    			this->buttonB->Size = System::Drawing::Size(90, 54);
    			this->buttonB->TabIndex = 11;
    			this->buttonB->Text = L"#";
    			this->buttonB->UseVisualStyleBackColor = true;
    			this->buttonB->Click += gcnew System::EventHandler(this, &MyForm::buttonB_Click);
    			// 
    			// timerInactive
    			// 
    			this->timerInactive->Tick += gcnew System::EventHandler(this, &MyForm::timerInaktive_Tick);
    			// 
    			// label1
    			// 
    			this->label1->BackColor = System::Drawing::SystemColors::Info;
    			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 27.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->label1->Location = System::Drawing::Point(7, 8);
    			this->label1->Name = L"label1";
    			this->label1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
    			this->label1->Size = System::Drawing::Size(280, 48);
    			this->label1->TabIndex = 14;
    			// 
    			// label2
    			// 
    			this->label2->BackColor = System::Drawing::SystemColors::Info;
    			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->label2->Location = System::Drawing::Point(7, 56);
    			this->label2->Name = L"label2";
    			this->label2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
    			this->label2->Size = System::Drawing::Size(280, 27);
    			this->label2->TabIndex = 15;
    			this->label2->Text = L"Nutzerkennungseingabe";
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->BackColor = System::Drawing::Color::Red;
    			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->label3->Location = System::Drawing::Point(79, 94);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(46, 16);
    			this->label3->TabIndex = 16;
    			this->label3->Text = L"OPEN";
    			// 
    			// label4
    			// 
    			this->label4->AutoSize = true;
    			this->label4->BackColor = System::Drawing::Color::Red;
    			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
    				static_cast<System::Byte>(0)));
    			this->label4->Location = System::Drawing::Point(166, 94);
    			this->label4->Name = L"label4";
    			this->label4->Size = System::Drawing::Size(81, 16);
    			this->label4->TabIndex = 17;
    			this->label4->Text = L"UNLOCKED";
    			// 
    			// timerLock
    			// 
    			this->timerLock->Tick += gcnew System::EventHandler(this, &MyForm::timerLock_Tick);
    			// 
    			// MyForm
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(296, 364);
    			this->Controls->Add(this->label4);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->buttonB);
    			this->Controls->Add(this->buttonC);
    			this->Controls->Add(this->button0);
    			this->Controls->Add(this->button7);
    			this->Controls->Add(this->button8);
    			this->Controls->Add(this->button9);
    			this->Controls->Add(this->button6);
    			this->Controls->Add(this->button4);
    			this->Controls->Add(this->button5);
    			this->Controls->Add(this->button3);
    			this->Controls->Add(this->button2);
    			this->Controls->Add(this->button1);
    			this->MaximizeBox = false;
    			this->Name = L"MyForm";
    			this->Text = L"MyForm";
    			this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void button0_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button0->Text);
    }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button1->Text);
    }
    private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button2->Text);
    }
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button3->Text);
    }
    private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button4->Text);
    }
    private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button5->Text);
    }
    private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button6->Text);
    }
    private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button7->Text);
    }
    private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button8->Text);
    }
    private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
    	this->AddDigit(button9->Text);
    }
    private: System::Void buttonC_Click(System::Object^  sender, System::EventArgs^  e) {
    	if ((str_input_buffer->Length > 0) && (label1->Text->Length > 0))
    	{
    		this->str_input_buffer = this->str_input_buffer->Substring(0, str_input_buffer->Length - 1);
    		this->label1->Text = label1->Text->Substring(0, label1->Text->Length - 1);
    		this->TimerInactiveReset();
    	}
    	if (bo_master_mode_request)
    	{
    		label2->Text = TEXT_INPUT_MASTERCODE;
    	}
    	else
    	{
    		if (bo_id_checked)
    		{
    			label2->Text = TEXT_INPUT_CODE;
    		}
    		else
    		{
    			label2->Text = TEXT_INPUT_ID;
    		}
    	}
    }
    private: System::Void buttonB_Click(System::Object^  sender, System::EventArgs^  e) {
    	DoorLocking();
    	label2->Text = "";
    	if (bo_master_mode_en == false)
    	{
    		if (bo_master_mode_request == false)
    		{
    			if (bo_id_checked == false)
    			{
    				if (str_input_buffer == "0")
    				{
    					bo_master_mode_request = true;
    					label2->Text = TEXT_INPUT_MASTERCODE;
    					ClearBufferScreen();
    				}
    				else
    				{
    					if (bo_CheckId())
    					{
    						bo_id_checked = true;
    						label2->Text = TEXT_INPUT_CODE;
    					}
    					else
    					{
    						bo_id_checked = false;
    						label2->Text = TEXT_INPUT_ID;
    					}
    				}
    			}
    			else
    			{
    				if (bo_CheckCode())										
    				{
    					label2->Text = TEXT_CODE_SUCCESS;
    					DoorUnlocking();
    					//
    					//
    					//do something when code is right
    				}
    				else
    				{
    					bo_id_checked = false;
    					label2->Text = TEXT_INPUT_ID;
    					//
    					//
    					//do something when code is right
    				}
    
    			}
    		}
    		else
    		{
    			if (bo_CheckMasterCode())
    			{
    				bo_master_mode_en = true;
    				label2->Text = "Mater-Mode";
    			}
    			else
    			{
    				bo_master_mode_request = false;
    				label2->Text = TEXT_INPUT_ID;
    			}
    			ClearBufferScreen();
    		}
    	}
    	else
    	{
    		bo_master_mode_en = false;
    		label2->Text = TEXT_INPUT_ID;
    	}
    	ClearBufferScreen();
    	TimerInactiveReset();
    }
    private: System::Void timerInaktive_Tick(System::Object^  sender, System::EventArgs^  e) {
    	timerInactive->Stop();
    	bo_id_checked = false;
    	bo_master_mode_request = false;
    	bo_master_mode_en = false;
    	ClearBufferScreen();
    	label2->Text = TEXT_INPUT_ID;
    }
    private: System::Void timerLock_Tick(System::Object^  sender, System::EventArgs^  e) {
    	DoorLocking();
    }
    
    };
    
    void MyForm::ClearBufferScreen()
    {
    	this->str_input_buffer = "";
    	this->label1->Text = "";
    }
    
    void MyForm::TimerInactiveReset()
    {
    	timerInactive->Stop();
    	timerInactive->Interval = BUFFER_LIFETIME;
    	timerInactive->Start();
    }
    
    void MyForm::AddDigit(String ^digit)
    {
    	if ((bo_id_checked == true) || (bo_master_mode_request == true))
    	{
    		if (str_input_buffer->Length >= MAX_CODE_LENGTH)
    		{
    			str_input_buffer = str_input_buffer->Substring(0, str_input_buffer->Length - 1);
    			str_input_buffer += digit;
    			label2->Text = "Zuviele Ziffern";
    		}
    		else
    		{
    			str_input_buffer += digit;
    			label1->Text += "*";
    		}
    	}
    	else
    	{
    		if (str_input_buffer->Length >= MAX_ID_LENGTH)
    		{
    			str_input_buffer = str_input_buffer->Substring(0, str_input_buffer->Length - 1);
    			str_input_buffer += digit;
    			label2->Text = "Zuviele Ziffern";
    		}
    		else
    		{
    			str_input_buffer += digit;
    			label1->Text = "#" + str_input_buffer;
    		}
    	}
    	TimerInactiveReset();
    }
    
    bool MyForm::bo_CheckId()
    {
    	uint_id_current = System::Convert::ToInt16(str_input_buffer);
    	if (uint_id_current != ID){
    		return false;
    	}
    	if (uint_id_current > NUMBER_OF_USERS) {
    		return false;
    	}
    	return true;
    }
    
    bool MyForm::bo_CheckCode(void)
    {
    	if (str_input_buffer == CODE)
    	{
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    }
    
    bool MyForm::bo_CheckMasterCode(void)
    {
    	if (str_input_buffer == MASTER_CODE)
    	{
    		return true;
    	}
    	return false;
    }
    
    void MyForm::DoorUnlocking()
    {
    	bo_door_unlocked = true;
    	label4->BackColor = System::Drawing::Color::Green;
    	timerLock->Start();
    	timerLock->Interval = UNLOCK_TIME;
    	timerLock->Start();
    }
    
    void MyForm::DoorLocking()
    {
    	timerLock->Stop();
    	bo_door_unlocked = false;
    	this->label4->BackColor = System::Drawing::Color::Red;
    }
    
    }
    

    vielen Dank für die Zeit im Vorraus 🙂



  • Hallo,

    setze die Array-Initialisierung in den Konstruktur.



  • danke dir für die schnelle Antwort nur leider löst das mein Problem auch nicht.
    Ich hab schon ein Problem bei der Deklaration des Arrays als Attribute, bis zur Definition in der im Konstruktor bin ich noch gar nicht gekommen 😕



  • array<Users^> ^ar = gcnew array<Users^>(NUMBER_OF_USERS);
    

    Edit:
    ... und #include <array> ist nicht nötig, da es sich um ein .NET Array handelt.

    Edit2:
    ... und #include <string> ist nicht nötig, da es sich um .NET Strings handelt.



  • Ich weiß schon warum ich C++/CLI nicht mag. - Immer das umdenken wenn es sich um Managed Typen handelt, wie diese zu verwenden sind... Ein graus dieses "^".



  • danke für die Antworten 🙂
    Leider werden mir, auch mit der oben genannten Zeile, immer noch Fehler angezeigt (siehe Link) und ich weißt nicht warum 😕

    Wenn ich als zweites Argument für die Arraygröße "1" ergänze sind die ersten zwei Fehler erledigt.

    Ich hoffe jemand von euch was auch für die restlichen Fehler Abhilfe 🙂

    http://img5.fotos-hochladen.net/uploads/fehlerav1gl58t4d.jpg



  • Hallo jonen,

    du vermischst .NET Typen mit C++ Typen. Das solltest du vermeiden. std:array ist für deinen Typen einfach das falsche.

    theta hat dich ja bereits darauf hingewiesen, dass du das Include auf std:array weglassen sollst.



  • Hallo jonen,

    warum benutzt du überhaupt C++/CLI? Für WinForms solltest du C# verwenden, s.a. Windows Forms und Visual C++ MACHT KEINEN SINN!.



  • Das using namespace std; führt mit dem include-Statement zusammen dann zum Problem. using namespace std; ist generell nicht eine sehr gute Idee und führt schnell zu Problemen.


Anmelden zum Antworten