Visual studio c++ Windows form prosta struktura

0

Witam,

mam niby prosty problem którego nie potrafię rozwikłać.

Chcę w aplikacji okienkowej utworzonej w Visual studio c++ utworzyć prostą strukturę która zawiera dwa pola typu string: imie i nazwisko. Następnie chciałbym utworzyć tablice typu danej struktury i od razu uzupełnić ją nazwiskami.

Niestety dostaje błędy związane zarówno z użyciem string jak i samej struktury.

Gdzie powinienem zadeklarować daną strukture i jak to zrobić, czy może użyć czegoś co oferuje VS?

0
  1. Pokaż swój kod.
  2. Może zanim zaczniesz pisać aplikacje okienkowe, powinieneś poświęcić trochę czasu na naukę podstaw języka?
0
  1. kod
#pragma once
#include <string>

namespace stu {

	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 std;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		/// <summary>
		struct Struktura
		{
			string name;
			string surname;
		};
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#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->SuspendLayout();
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(292, 273);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
			 }
	};
}



1>c:\users\szary\documents\visual studio 2005\projects\stu\stu\Form1.h(49) : error C2814: 'stu::Form1::Struktura' : a native type cannot be nested within a managed type 'stu::Form1'
1>        c:\users\szary\documents\visual studio 2005\projects\stu\stu\Form1.h(23) : see declaration of 'stu::Form1'

2.Znam podstawy języka c++ i jestem tutaj bo właśnie próbuję się czegoś nauczyć.

0
 value struct Struktura
 {
      String^ name;
      String^ surname;
 };

1 użytkowników online, w tym zalogowanych: 0, gości: 1