Hello Ciaran,
Excuse may you can help me a little bit more:
I created a very tiny project with a form and a button on it.
It has two classes each with one int as private property and access
functions (Get/Set).
My problem is like this:
I've a breakpoint in "myClassB->SetmyClassBVariable(7);" in the button
routine. So
my "program counter" is at:
myClassBVariable = what;
Now I want to know what is the Variable in myClassA now - Which is not
possible to me.
I tried something with static with the "watchIt" of Type MyClassA.
But it doesn't work also.
I thought when I am at the breakpoint in line "myClassBVariable = what;" i
could access everything
(at least visualise it) as it definitely is somewhere in the RAM.
Would be nice if you or
someoneelse could help me with my misunderstandings,
Regards, Greg.
P.S.: The real project is indeed somewhat more complicated. ClassA has a
static method returning the instance
of the object which is more than obscure to me - but o.k. it works so I'm
not interested in.
The only thing which does not fit into my mind is that it should be possible
to inspect every tiny variable in the program
as there value's positions in RAM are known to the debugger ?!.
-------------------------------------------------------------------------------------------------------------------
This is a small project explaining my problem:
-------------------------------------------------------------------------------------------------------------------
#pragma once
namespace Test5 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:
ata;
using namespace System:
rawing;
public class MyClassA
{
public: void SetmyClassAVariable(int what) {myClassAVariable = what;}
public: int GetmyClassAVariable(void) {return myClassAVariable;}
private: int myClassAVariable;
};
public class MyClassB
{
public: void SetmyClassBVariable(int what)
{
myClassBVariable = what;// make Breakpoint here at ButtonClick and try to
watch the other classA variables.************************
}
private: int myClassBVariable;
};
/// <summary>
/// Zusammenfassung für Form1
///
/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
/// die Ressourcendateiname-Eigenschaft für das Tool zur
Kompilierung verwalteter Ressourcen ändern,
/// das allen RESX-Dateien zugewiesen ist, von denen diese Klasse
abhängt.
/// Anderenfalls können die Designer nicht korrekt mit den
lokalisierten Ressourcen
/// arbeiten, die diesem Formular zugewiesen sind.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
private: MyClassA * myClassA;
private: MyClassB * myClassB;
public: static MyClassA * watchIt;
public:
Form1(void)
{
myClassA = new MyClassA();
myClassA->SetmyClassAVariable(5);
myClassB = new MyClassB();
watchIt = new MyClassA();
watchIt->SetmyClassAVariable(100);
watchIt = myClassA;
InitializeComponent();
//
//TODO: Konstruktorcode hier hinzufügen.
//
}
protected:
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System:
rawing:
oint(12, 12);
this->button1->Name = L"button1";
this->button1->Size = System:
rawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this,
&Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System:
rawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System:
rawing::Size(292, 273);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
myClassB->SetmyClassBVariable(7);
button1->Text = watchIt->GetmyClassAVariable().ToString();
}
};
}