[VS C++] wzajemne oddziałowanie 2 klas


(Przemekbaranowski) #1

Piszę program, są tam 2 klasy: Form1 i Core.

Metody z klasy Form1 (np buttonClick) wywołują metody z klasy Core - implementacja wywołania w Form1.cpp

Chciałbym też, żeby jednocześnie metody z klasy Core mogły zadziałać na formatce (Form1),

Core.cpp

#include "StdAfx.h"

#include "Core.h"

#include 

#include 

#include 


data_generator_2::Core::Core(void)

{

	this->s_imiona = 900000;

	this->s_nazwiska = 100;

	this->s_ulice = 500;

	this->s_miasta = 700;

	this->s_rodzaje = 50;

	this->s_producenci = 51;


	this->s_word1 = 25;

	this->s_word2 = 40;

	this->s_word3 = 100;


}


System::Void data_generator_2::Core::malloc_tables(data_generator_2::Form1^ f1)

{

	this->imiona_m = (char**) malloc(this->s_imiona * sizeof(char*));

	for (int i=0;is_imiona;i++) this->imiona_m[i] = (char*)malloc(this->s_word1 * sizeof(char));  

	this->imiona_k = (char**) malloc(this->s_imiona * sizeof(char*));

	for (int i=0;is_imiona;i++) this->imiona_k[i] = (char*)malloc(this->s_word1 * sizeof(char));

	this->nazwiska_m = (char**) malloc(this->s_nazwiska * sizeof(char*));

	for (int i=0;is_nazwiska;i++) this->nazwiska_m[i] = (char*)malloc(this->s_word1 * sizeof(char));

	this->nazwiska_k = (char**) malloc(this->s_nazwiska * sizeof(char*));

	for (int i=0;is_nazwiska;i++) this->nazwiska_k[i] = (char*)malloc(this->s_word1 * sizeof(char));

	this->ulice = (char**)malloc(this->s_ulice * sizeof(char*));

	for (int i=0;is_ulice;i++) this->ulice[i] = (char*)malloc(this->s_word2 * sizeof(char));

	this->rodzaje = (char**)malloc(this->s_rodzaje * sizeof(char*));

	for (int i=0;is_rodzaje;i++) this->rodzaje[i] = (char*)malloc(this->s_word2 * sizeof(char));

	this->producenci = (char**)malloc(this->s_producenci * sizeof(char*));

	for (int i=0;is_producenci;i++) this->producenci[i] = (char*)malloc(this->s_word3 * sizeof(char));

	this->miasta = (struct miasta_*)malloc(this->s_miasta * sizeof(struct miasta_));

	for (int i=0;is_miasta;i++) this->miasta[i].nazwa = (char*)malloc(this->s_word2 * sizeof(char));	


	f1->textBox1->AppendText(String::Format("{0}	Zaalokowano pamięć",System::DateTime::UtcNow));

	//data_generator_2::Form1::textBox1->AppendText(String::Format("{0}	Zaalokowano pamięć",System::DateTime::UtcNow));

}

System::Void data_generator_2::Core::free_tables(void)

{

	for(int i=0;is_imiona;i++) free(this->imiona_m[i]);

	free(this->imiona_m);

	for(int i=0;is_imiona;i++) free(this->imiona_k[i]);

	free(this->imiona_k);

	for(int i=0;is_nazwiska;i++) free(this->nazwiska_m[i]);

	free(this->nazwiska_m);

	for(int i=0;is_nazwiska;i++) free(this->nazwiska_k[i]);

	free(this->nazwiska_k);

	for(int i=0;is_ulice;i++) free(this->ulice[i]);

	free(this->ulice);

	for(int i=0;is_rodzaje;i++) free(this->rodzaje[i]);

	free(this->rodzaje);

	for(int i=0;is_producenci;i++) free(this->producenci[i]);

	free(this->producenci);

	for (int i=0;is_miasta;i++) free(this->miasta[i].nazwa);

	free(this->miasta);

}

Core.h

#pragma once

#include "stdafx.h"


namespace data_generator_2 {


	using namespace System;

	using namespace System::ComponentModel;

	using namespace System::Collections;

	using namespace System::Windows::Forms;

	using namespace System::Data;

	using namespace System::Drawing;




struct miasta_

{

	char *nazwa;

	int wielkosc;

};


public ref class Core

{

//rozmiary tablic znaków

public: int s_imiona;

public: int s_nazwiska;

public: int s_ulice;

public: int s_miasta;

public: int s_rodzaje;

public: int s_producenci;

public: int s_word1;

public: int s_word2;

public: int s_word3;


//tablice znaków

public: char **imiona_m;

public: char **imiona_k;

public: char **nazwiska_m;

public: char **nazwiska_k;

public: char **ulice;

public: struct miasta_ *miasta;

public: char **rodzaje;

public: char **producenci;


//METODY

public:Core(void);

public: System::Void malloc_tables(data_generator_2::Form1^ f1);

public: System::Void free_tables(void);




};//class



}//namespace

Form1.cpp

#include "StdAfx.h"

#include "Form1.h"


System::Void data_generator_2::Form1::button1_Click(System::Object^ sender, System::EventArgs^ e) 

{

	this->cor->malloc_tables(this);

	this->cor->free_tables();

}//GENERUJ

System::Void data_generator_2::Form1::button2_Click(System::Object^ sender, System::EventArgs^ e) 

{

	this->textBox1->Clear();				 

}//clear log

Form1.h

#pragma once

#include "stdafx.h"

#include "Core.h"



namespace data_generator_2 {


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


	/// 

	/// 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.

	/// 

	public ref class Form1 : public System::Windows::Forms::Form

	{

	public:

		Form1(void)

		{

			InitializeComponent();

			cor = gcnew data_generator_2::Core();


			//

			//TODO: Add the constructor code here

			//

		}


	protected:

		/// 

		/// Clean up any resources being used.

		/// 

		~Form1()

		{

			if (components)

			{

				delete components;

			}

		}

	private: System::Windows::Forms::GroupBox^ groupBox1;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown6;

	private: 

	public: System::Windows::Forms::NumericUpDown^ numericUpDown5;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown4;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown3;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown2;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown1;

	public: System::Windows::Forms::DateTimePicker^ dateTimePicker2;

	public: System::Windows::Forms::DateTimePicker^ dateTimePicker1;

	protected: 



	public:data_generator_2::Core^ cor;






	private: System::Windows::Forms::Label^ label7;

	private: System::Windows::Forms::Label^ label6;

	private: System::Windows::Forms::Label^ label5;

	private: System::Windows::Forms::Label^ label4;

	private: System::Windows::Forms::Label^ label3;

	private: System::Windows::Forms::Label^ label2;

	private: System::Windows::Forms::Label^ label1;

	private: System::Windows::Forms::Label^ label10;

	private: System::Windows::Forms::Label^ label9;

	private: System::Windows::Forms::Label^ label8;

	public: System::Windows::Forms::NumericUpDown^ numericUpDown7;

	private: 

	public: System::Windows::Forms::Button^ button1;

	public: System::Windows::Forms::TextBox^ textBox1;

	private: System::Windows::Forms::Label^ label11;

	public: 

	public: System::Windows::Forms::RadioButton^ radioButton1;

	private: 

	public: System::Windows::Forms::RadioButton^ radioButton2;

	public: System::Windows::Forms::RadioButton^ radioButton3;

	public: System::Windows::Forms::Button^ button2;


	private:

		/// 

		/// Required designer variable.

		/// 

		System::ComponentModel::Container ^components;


#pragma region Windows Form Designer generated code

		/// 

		/// Required method for Designer support - do not modify

		/// the contents of this method with the code editor.

		/// 

		void InitializeComponent(void)

		{

			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());

			this->label10 = (gcnew System::Windows::Forms::Label());

			this->label9 = (gcnew System::Windows::Forms::Label());

			this->label8 = (gcnew System::Windows::Forms::Label());

			this->numericUpDown7 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown6 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown5 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown4 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());

			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());

			this->dateTimePicker2 = (gcnew System::Windows::Forms::DateTimePicker());

			this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());

			this->label7 = (gcnew System::Windows::Forms::Label());

			this->label6 = (gcnew System::Windows::Forms::Label());

			this->label5 = (gcnew System::Windows::Forms::Label());

			this->label4 = (gcnew System::Windows::Forms::Label());

			this->label3 = (gcnew System::Windows::Forms::Label());

			this->label2 = (gcnew System::Windows::Forms::Label());

			this->label1 = (gcnew System::Windows::Forms::Label());

			this->button1 = (gcnew System::Windows::Forms::Button());

			this->textBox1 = (gcnew System::Windows::Forms::TextBox());

			this->label11 = (gcnew System::Windows::Forms::Label());

			this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());

			this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());

			this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());

			this->button2 = (gcnew System::Windows::Forms::Button());

			this->groupBox1->SuspendLayout();

			(cli::safe_cast(this->numericUpDown7))->BeginInit();

			(cli::safe_cast(this->numericUpDown6))->BeginInit();

			(cli::safe_cast(this->numericUpDown5))->BeginInit();

			(cli::safe_cast(this->numericUpDown4))->BeginInit();

			(cli::safe_cast(this->numericUpDown3))->BeginInit();

			(cli::safe_cast(this->numericUpDown2))->BeginInit();

			(cli::safe_cast(this->numericUpDown1))->BeginInit();

			this->SuspendLayout();

			// 

			// groupBox1

			// 

			this->groupBox1->Controls->Add(this->label10);

			this->groupBox1->Controls->Add(this->label9);

			this->groupBox1->Controls->Add(this->label8);

			this->groupBox1->Controls->Add(this->numericUpDown7);

			this->groupBox1->Controls->Add(this->numericUpDown6);

			this->groupBox1->Controls->Add(this->numericUpDown5);

			this->groupBox1->Controls->Add(this->numericUpDown4);

			this->groupBox1->Controls->Add(this->numericUpDown3);

			this->groupBox1->Controls->Add(this->numericUpDown2);

			this->groupBox1->Controls->Add(this->numericUpDown1);

			this->groupBox1->Controls->Add(this->dateTimePicker2);

			this->groupBox1->Controls->Add(this->dateTimePicker1);

			this->groupBox1->Controls->Add(this->label7);

			this->groupBox1->Controls->Add(this->label6);

			this->groupBox1->Controls->Add(this->label5);

			this->groupBox1->Controls->Add(this->label4);

			this->groupBox1->Controls->Add(this->label3);

			this->groupBox1->Controls->Add(this->label2);

			this->groupBox1->Controls->Add(this->label1);

			this->groupBox1->Location = System::Drawing::Point(12, 12);

			this->groupBox1->Name = L"groupBox1";

			this->groupBox1->Size = System::Drawing::Size(553, 168);

			this->groupBox1->TabIndex = 0;

			this->groupBox1->TabStop = false;

			this->groupBox1->Text = L"groupBox1";

			// 

			// label10

			// 

			this->label10->AutoSize = true;

			this->label10->Location = System::Drawing::Point(331, 20);

			this->label10->Name = L"label10";

			this->label10->Size = System::Drawing::Size(22, 13);

			this->label10->TabIndex = 18;

			this->label10->Text = L"do:";

			// 

			// label9

			// 

			this->label9->AutoSize = true;

			this->label9->Location = System::Drawing::Point(153, 16);

			this->label9->Name = L"label9";

			this->label9->Size = System::Drawing::Size(22, 13);

			this->label9->TabIndex = 17;

			this->label9->Text = L"od:";

			// 

			// label8

			// 

			this->label8->AutoSize = true;

			this->label8->Location = System::Drawing::Point(85, 141);

			this->label8->Name = L"label8";

			this->label8->Size = System::Drawing::Size(90, 13);

			this->label8->TabIndex = 16;

			this->label8->Text = L"stale pracujących";

			// 

			// numericUpDown7

			// 

			this->numericUpDown7->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown7->Location = System::Drawing::Point(449, 113);

			this->numericUpDown7->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100000000, 0, 0, 0});

			this->numericUpDown7->Name = L"numericUpDown7";

			this->numericUpDown7->Size = System::Drawing::Size(98, 20);

			this->numericUpDown7->TabIndex = 15;

			this->numericUpDown7->ThousandsSeparator = true;

			// 

			// numericUpDown6

			// 

			this->numericUpDown6->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, 0});

			this->numericUpDown6->Location = System::Drawing::Point(449, 83);

			this->numericUpDown6->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100000, 0, 0, 0});

			this->numericUpDown6->Name = L"numericUpDown6";

			this->numericUpDown6->Size = System::Drawing::Size(98, 20);

			this->numericUpDown6->TabIndex = 14;

			this->numericUpDown6->ThousandsSeparator = true;

			// 

			// numericUpDown5

			// 

			this->numericUpDown5->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0});

			this->numericUpDown5->Location = System::Drawing::Point(449, 54);

			this->numericUpDown5->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown5->Name = L"numericUpDown5";

			this->numericUpDown5->Size = System::Drawing::Size(98, 20);

			this->numericUpDown5->TabIndex = 13;

			this->numericUpDown5->ThousandsSeparator = true;

			// 

			// numericUpDown4

			// 

			this->numericUpDown4->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});

			this->numericUpDown4->Location = System::Drawing::Point(181, 139);

			this->numericUpDown4->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown4->Name = L"numericUpDown4";

			this->numericUpDown4->Size = System::Drawing::Size(61, 20);

			this->numericUpDown4->TabIndex = 12;

			this->numericUpDown4->ThousandsSeparator = true;

			// 

			// numericUpDown3

			// 

			this->numericUpDown3->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0});

			this->numericUpDown3->Location = System::Drawing::Point(144, 113);

			this->numericUpDown3->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown3->Name = L"numericUpDown3";

			this->numericUpDown3->Size = System::Drawing::Size(98, 20);

			this->numericUpDown3->TabIndex = 11;

			this->numericUpDown3->ThousandsSeparator = true;

			// 

			// numericUpDown2

			// 

			this->numericUpDown2->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {50, 0, 0, 0});

			this->numericUpDown2->Location = System::Drawing::Point(144, 83);

			this->numericUpDown2->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown2->Name = L"numericUpDown2";

			this->numericUpDown2->Size = System::Drawing::Size(98, 20);

			this->numericUpDown2->TabIndex = 10;

			this->numericUpDown2->ThousandsSeparator = true;

			// 

			// numericUpDown1

			// 

			this->numericUpDown1->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});

			this->numericUpDown1->Location = System::Drawing::Point(144, 54);

			this->numericUpDown1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000000, 0, 0, 0});

			this->numericUpDown1->Name = L"numericUpDown1";

			this->numericUpDown1->Size = System::Drawing::Size(98, 20);

			this->numericUpDown1->TabIndex = 9;

			this->numericUpDown1->ThousandsSeparator = true;

			// 

			// dateTimePicker2

			// 

			this->dateTimePicker2->Location = System::Drawing::Point(359, 16);

			this->dateTimePicker2->Name = L"dateTimePicker2";

			this->dateTimePicker2->Size = System::Drawing::Size(142, 20);

			this->dateTimePicker2->TabIndex = 8;

			// 

			// dateTimePicker1

			// 

			this->dateTimePicker1->Location = System::Drawing::Point(181, 15);

			this->dateTimePicker1->Name = L"dateTimePicker1";

			this->dateTimePicker1->Size = System::Drawing::Size(142, 20);

			this->dateTimePicker1->TabIndex = 7;

			// 

			// label7

			// 

			this->label7->AutoSize = true;

			this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label7->Location = System::Drawing::Point(326, 113);

			this->label7->Name = L"label7";

			this->label7->Size = System::Drawing::Size(107, 16);

			this->label7->TabIndex = 6;

			this->label7->Text = L"Liczba transakcji";

			// 

			// label6

			// 

			this->label6->AutoSize = true;

			this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label6->Location = System::Drawing::Point(326, 83);

			this->label6->Name = L"label6";

			this->label6->Size = System::Drawing::Size(112, 16);

			this->label6->TabIndex = 5;

			this->label6->Text = L"Liczba produktów";

			// 

			// label5

			// 

			this->label5->AutoSize = true;

			this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label5->Location = System::Drawing::Point(326, 54);

			this->label5->Name = L"label5";

			this->label5->Size = System::Drawing::Size(117, 16);

			this->label5->TabIndex = 4;

			this->label5->Text = L"Liczba dostawców";

			// 

			// label4

			// 

			this->label4->AutoSize = true;

			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label4->Location = System::Drawing::Point(7, 113);

			this->label4->Name = L"label4";

			this->label4->Size = System::Drawing::Size(128, 16);

			this->label4->TabIndex = 3;

			this->label4->Text = L"Liczba pracowników";

			// 

			// label3

			// 

			this->label3->AutoSize = true;

			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label3->Location = System::Drawing::Point(7, 83);

			this->label3->Name = L"label3";

			this->label3->Size = System::Drawing::Size(82, 16);

			this->label3->TabIndex = 2;

			this->label3->Text = L"Liczba miast";

			// 

			// label2

			// 

			this->label2->AutoSize = true;

			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label2->Location = System::Drawing::Point(7, 54);

			this->label2->Name = L"label2";

			this->label2->Size = System::Drawing::Size(98, 16);

			this->label2->TabIndex = 1;

			this->label2->Text = L"Liczba klientów";

			// 

			// label1

			// 

			this->label1->AutoSize = true;

			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->label1->Location = System::Drawing::Point(7, 20);

			this->label1->Name = L"label1";

			this->label1->Size = System::Drawing::Size(135, 16);

			this->label1->TabIndex = 0;

			this->label1->Text = L"Okres działania firmy";

			// 

			// button1

			// 

			this->button1->Font = (gcnew System::Drawing::Font(L"Monotype Corsiva", 15, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->button1->Location = System::Drawing::Point(208, 188);

			this->button1->Name = L"button1";

			this->button1->Size = System::Drawing::Size(157, 34);

			this->button1->TabIndex = 1;

			this->button1->Text = L"GENERUJ!";

			this->button1->UseVisualStyleBackColor = true;

			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);

			// 

			// textBox1

			// 

			this->textBox1->Location = System::Drawing::Point(12, 239);

			this->textBox1->Multiline = true;

			this->textBox1->Name = L"textBox1";

			this->textBox1->Size = System::Drawing::Size(553, 180);

			this->textBox1->TabIndex = 2;

			// 

			// label11

			// 

			this->label11->AutoSize = true;

			this->label11->Location = System::Drawing::Point(76, 225);

			this->label11->Name = L"label11";

			this->label11->Size = System::Drawing::Size(192, 13);

			this->label11->TabIndex = 3;

			this->label11->Text = L"Wybierz predefiniowaną wielkość bazy:";

			// 

			// radioButton1

			// 

			this->radioButton1->AutoSize = true;

			this->radioButton1->Location = System::Drawing::Point(274, 223);

			this->radioButton1->Name = L"radioButton1";

			this->radioButton1->Size = System::Drawing::Size(49, 17);

			this->radioButton1->TabIndex = 4;

			this->radioButton1->TabStop = true;

			this->radioButton1->Text = L"mała";

			this->radioButton1->UseVisualStyleBackColor = true;

			// 

			// radioButton2

			// 

			this->radioButton2->AutoSize = true;

			this->radioButton2->Location = System::Drawing::Point(329, 221);

			this->radioButton2->Name = L"radioButton2";

			this->radioButton2->Size = System::Drawing::Size(59, 17);

			this->radioButton2->TabIndex = 5;

			this->radioButton2->TabStop = true;

			this->radioButton2->Text = L"średnia";

			this->radioButton2->UseVisualStyleBackColor = true;

			// 

			// radioButton3

			// 

			this->radioButton3->AutoSize = true;

			this->radioButton3->Location = System::Drawing::Point(389, 221);

			this->radioButton3->Name = L"radioButton3";

			this->radioButton3->Size = System::Drawing::Size(48, 17);

			this->radioButton3->TabIndex = 6;

			this->radioButton3->TabStop = true;

			this->radioButton3->Text = L"duża";

			this->radioButton3->UseVisualStyleBackColor = true;

			// 

			// button2

			// 

			this->button2->FlatStyle = System::Windows::Forms::FlatStyle::System;

			this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 7, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 

				static_cast(238)));

			this->button2->Location = System::Drawing::Point(504, 226);

			this->button2->Name = L"button2";

			this->button2->Size = System::Drawing::Size(61, 12);

			this->button2->TabIndex = 7;

			this->button2->Text = L"czyść logi";

			this->button2->UseVisualStyleBackColor = true;

			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);

			// 

			// Form1

			// 

			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

			this->BackColor = System::Drawing::Color::YellowGreen;

			this->ClientSize = System::Drawing::Size(577, 421);

			this->Controls->Add(this->button2);

			this->Controls->Add(this->radioButton3);

			this->Controls->Add(this->radioButton2);

			this->Controls->Add(this->radioButton1);

			this->Controls->Add(this->label11);

			this->Controls->Add(this->textBox1);

			this->Controls->Add(this->button1);

			this->Controls->Add(this->groupBox1);

			this->Name = L"Form1";

			this->Text = L"Form1";

			this->groupBox1->ResumeLayout(false);

			this->groupBox1->PerformLayout();

			(cli::safe_cast(this->numericUpDown7))->EndInit();

			(cli::safe_cast(this->numericUpDown6))->EndInit();

			(cli::safe_cast(this->numericUpDown5))->EndInit();

			(cli::safe_cast(this->numericUpDown4))->EndInit();

			(cli::safe_cast(this->numericUpDown3))->EndInit();

			(cli::safe_cast(this->numericUpDown2))->EndInit();

			(cli::safe_cast(this->numericUpDown1))->EndInit();

			this->ResumeLayout(false);

			this->PerformLayout();


		}

#pragma endregion

	private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e);

	public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e);

};

}

Jak zrobić, żeby metoda Core::malloc_tables() mogła wywołać metodę f1->textBox1->AppendText() ? powyższy kod w trakcie kompilacji krzyczy:

(...)\Core.h(46) : error C2039: 'Form1' : is not a member of 'data_generator_2'

(...)\Core.h(46) : error C2061: syntax error : identifier 'Form1'

(Ryan) #2

Pytanie pojawiało się już dziesiątki razy na forum. Słowo klucz: prototyp klasy. Lub refaktoryzacja kodu. Często taka relacja między klasami oznacza źle zaprojektowany kod.


(Przemekbaranowski) #3

dzięki;) po prostu nie widziałem jak nazywa się to czego szuka, stąd nowy temat;) w takim razie temat do kosza;)