<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Zugriff auf Daten&#x2F;Methoden anderer Klassen]]></title><description><![CDATA[<p>Ich habe mal eine Frage zum Zugriff auf andere Klassen...</p>
<p>ich habe folgenden Pseudocode:</p>
<pre><code>class DatenObject :Widget
{
	int data1_;
	int handle(int event);
public:
	void data1(int i) {
		data1_ = i;
	}
}

DatenObject::DatenObject(Widget *parent){
	data1(0);
}

class MainObject : Window
{
	dataCell *data_cells_[5][5];
public:
	MainObject();
	~MainObject();
	void checkData(bool flag);
}
</code></pre>
<p>Im constructor vom MainObject lege ich mehrere Datenobjekte an:</p>
<pre><code>MainObject::MainObject :window(0)
{

	DatenObject *data;

	for	(i = 0;	i &lt; 5; i ++)
		for	(j = 0;	j &lt; 5; j ++) {
			data = new DatenObject(this);
			data_cells_[i][j] = data;
		}
}
</code></pre>
<p>in weiteren Methoden von MainObject werden die Daten manuell verändert<br />
und mit dieser Methode auf Konsistenz überprüft.</p>
<pre><code>void MainObject::checkData(bool flag) {
	code
}
</code></pre>
<p>nun möchte direkt nach der Dateneingabe den eingegebenen Wert in<br />
Abhängigkeit aller Werte im Array überprüfen mit dieser Methode</p>
<pre><code>int	DatenObject::handle(int event)
{
	code ?(MainObject::checkData(true))?
}
</code></pre>
<p>Wie rufe ich MainObject::checkData auf? komme einfach nicht weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161918/zugriff-auf-daten-methoden-anderer-klassen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 02:09:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161918.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Oct 2006 11:26:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 11:26:25 GMT]]></title><description><![CDATA[<p>Ich habe mal eine Frage zum Zugriff auf andere Klassen...</p>
<p>ich habe folgenden Pseudocode:</p>
<pre><code>class DatenObject :Widget
{
	int data1_;
	int handle(int event);
public:
	void data1(int i) {
		data1_ = i;
	}
}

DatenObject::DatenObject(Widget *parent){
	data1(0);
}

class MainObject : Window
{
	dataCell *data_cells_[5][5];
public:
	MainObject();
	~MainObject();
	void checkData(bool flag);
}
</code></pre>
<p>Im constructor vom MainObject lege ich mehrere Datenobjekte an:</p>
<pre><code>MainObject::MainObject :window(0)
{

	DatenObject *data;

	for	(i = 0;	i &lt; 5; i ++)
		for	(j = 0;	j &lt; 5; j ++) {
			data = new DatenObject(this);
			data_cells_[i][j] = data;
		}
}
</code></pre>
<p>in weiteren Methoden von MainObject werden die Daten manuell verändert<br />
und mit dieser Methode auf Konsistenz überprüft.</p>
<pre><code>void MainObject::checkData(bool flag) {
	code
}
</code></pre>
<p>nun möchte direkt nach der Dateneingabe den eingegebenen Wert in<br />
Abhängigkeit aller Werte im Array überprüfen mit dieser Methode</p>
<pre><code>int	DatenObject::handle(int event)
{
	code ?(MainObject::checkData(true))?
}
</code></pre>
<p>Wie rufe ich MainObject::checkData auf? komme einfach nicht weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153452</guid><dc:creator><![CDATA[walter sparbier]]></dc:creator><pubDate>Thu, 12 Oct 2006 11:26:25 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 11:31:54 GMT]]></title><description><![CDATA[<p>Erstmal ist eine Klasse nur ein Bauplan für Objekte - um damit arbeiten zu können, mußt du ein konkretes Objekt von dieser Klasse anlegen (z.B. als globales Objekt oder als Element der Klasse &quot;DatenObject&quot;).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153458</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 12 Oct 2006 11:31:54 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 11:42:04 GMT]]></title><description><![CDATA[<p>beim erzeugen von 'Datenobject' gibste ja schon einen pointer auf 'Mainobject' (parent) mit. den musste nur noch im 'Datenobject' speichern und dann: (MainObject*)parent-&gt;checkData(...) aufrufen ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153459</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Thu, 12 Oct 2006 11:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 11:34:34 GMT]]></title><description><![CDATA[<p>reinterpret_cast&lt;MainObject&gt;(parent)-&gt;checkData(...)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153462</guid><dc:creator><![CDATA[Knuddlbaer]]></dc:creator><pubDate>Thu, 12 Oct 2006 11:34:34 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 13:05:37 GMT]]></title><description><![CDATA[<p>Danke, so gehts jetzt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Auf reinterpret_cast&lt;MainObject*&gt;(parent)-&gt;checkData(true) wäre ich nie gekommen...</p>
<p>rein interessehalber:<br />
Wie löse ich das Problem wenn ich keinen Pointer auf MainObject übergebe (ist ja mehr &quot;zufällig&quot; wegen parent vom widget)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153579</guid><dc:creator><![CDATA[walter sparbier]]></dc:creator><pubDate>Thu, 12 Oct 2006 13:05:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 13:09:47 GMT]]></title><description><![CDATA[<p>walter sparbier schrieb:</p>
<blockquote>
<p>Wie löse ich das Problem wenn ich keinen Pointer auf MainObject übergebe (ist ja mehr &quot;zufällig&quot; wegen parent vom widget)?</p>
</blockquote>
<p>Indem Du zusätzlich einen Pointer (oder Referenz) auf das MainObject übergibst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153584</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Thu, 12 Oct 2006 13:09:47 GMT</pubDate></item><item><title><![CDATA[Reply to Zugriff auf Daten&#x2F;Methoden anderer Klassen on Thu, 12 Oct 2006 13:18:00 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>Indem Du zusätzlich einen Pointer (oder Referenz) auf das MainObject übergibst.</p>
</blockquote>
<p>...könnte man das nicht mit einer getInstance() Methode machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153594</guid><dc:creator><![CDATA[walter sparbier]]></dc:creator><pubDate>Thu, 12 Oct 2006 13:18:00 GMT</pubDate></item></channel></rss>