<?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[Typinformation]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgende Klasse:</p>
<pre><code class="language-cpp">class DT_FormatArg
	{
	public:
		DT_FormatArg(); 
		DT_FormatArg( long alValue ); 
		DT_FormatArg( char* apsValue ); 
		DT_FormatArg( DT_String&amp; acValue ); 

		void*	GetValue(); 
		bool	IsEmpty(); 

	private:
		void*	mpValue;
		bool	mbIsEmpty;
	};
</code></pre>
<p>Im Konstruktor kann ich der Klasse long, char* usw. mitgeben.</p>
<p>Jetzt stellt sich für mich die Frage: <strong>Was bist du?</strong> Ein Long, ein DT_String?<br />
Lässt sich soetwas überhaupt realisieren?</p>
<p>Merci</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124753/typinformation</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 01:42:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124753.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Oct 2005 10:37:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typinformation on Mon, 31 Oct 2005 10:37:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgende Klasse:</p>
<pre><code class="language-cpp">class DT_FormatArg
	{
	public:
		DT_FormatArg(); 
		DT_FormatArg( long alValue ); 
		DT_FormatArg( char* apsValue ); 
		DT_FormatArg( DT_String&amp; acValue ); 

		void*	GetValue(); 
		bool	IsEmpty(); 

	private:
		void*	mpValue;
		bool	mbIsEmpty;
	};
</code></pre>
<p>Im Konstruktor kann ich der Klasse long, char* usw. mitgeben.</p>
<p>Jetzt stellt sich für mich die Frage: <strong>Was bist du?</strong> Ein Long, ein DT_String?<br />
Lässt sich soetwas überhaupt realisieren?</p>
<p>Merci</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904382</guid><dc:creator><![CDATA[Tanzfreak]]></dc:creator><pubDate>Mon, 31 Oct 2005 10:37:04 GMT</pubDate></item><item><title><![CDATA[Reply to Typinformation on Mon, 31 Oct 2005 10:41:19 GMT]]></title><description><![CDATA[<p>warum arbeitest du nicht mit templates?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904390</guid><dc:creator><![CDATA[dr.prof]]></dc:creator><pubDate>Mon, 31 Oct 2005 10:41:19 GMT</pubDate></item><item><title><![CDATA[Reply to Typinformation on Mon, 31 Oct 2005 10:52:25 GMT]]></title><description><![CDATA[<p>Mal davon abgesehen, dass das etwas krude wirkt, könntest Du sowas wie einen Type-Tag speichern.</p>
<p>Z.B. enum Type { Long, String, WhatEver };</p>
<p>Der wird im Konstruktor entsprechend gesetzt und kann dann wieder abgefragt werden.</p>
<p>Templates sind hier nicht brauchbar, wenn man einen &quot;echten&quot; Variant will.<br />
(es entstehen viele unterschiedliche Typen, man will aber nur einen einzigen)</p>
<p>Eine tolle Artikelserie zu Variants kannst Du bei Interesse hier lesen:<br />
<a href="http://www.cuj.com/documents/s=7984/cujcexp2004alexandr/alexandr.htm" rel="nofollow">http://www.cuj.com/documents/s=7984/cujcexp2004alexandr/alexandr.htm</a><br />
<a href="http://www.cuj.com/documents/s=7982/cujcexp2006alexandr/alexandr.htm" rel="nofollow">http://www.cuj.com/documents/s=7982/cujcexp2006alexandr/alexandr.htm</a><br />
<a href="http://www.cuj.com/documents/s=7980/cujcexp2008alexandr/alexandr.htm" rel="nofollow">http://www.cuj.com/documents/s=7980/cujcexp2008alexandr/alexandr.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/904394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904394</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 31 Oct 2005 10:52:25 GMT</pubDate></item><item><title><![CDATA[Reply to Typinformation on Mon, 31 Oct 2005 11:10:55 GMT]]></title><description><![CDATA[<p>Tanzfreak schrieb:</p>
<blockquote>
<p>ich habe folgende Klasse:</p>
<pre><code class="language-cpp">class DT_FormatArg
	{
	public:
		DT_FormatArg(); 
		DT_FormatArg( long alValue ); 
		DT_FormatArg( char* apsValue ); 
		DT_FormatArg( DT_String&amp; acValue ); 

		void*	GetValue(); 
		bool	IsEmpty(); 

	private:
		void*	mpValue;
		bool	mbIsEmpty;
	};
</code></pre>
<p>Im Konstruktor kann ich der Klasse long, char* usw. mitgeben.</p>
<p>Jetzt stellt sich für mich die Frage: <strong>Was bist du?</strong> Ein Long, ein DT_String?<br />
Lässt sich soetwas überhaupt realisieren?<br />
Merci</p>
</blockquote>
<p>Und Polymorphie ist keine Möglichkeit?</p>
<pre><code class="language-cpp">class DT_FormatArg {
public:
   FormatArg (bool empty)
      : empty (empty)
   {}

   virtual void*	GetValue() = 0; 
   bool IsEmpty()
   { return empty; }

   protected:
      bool empty;
};

class DT_FormatArgLong : public FormatArg {
public:
   DT_FormatArgLong (long value)
      : FormatArg (false)
      , value (value)
   {}
   virtual void*	GetValue()
   {
      return &amp;value;
   }

private:
   long value;
};

... // ähnlich für andere Typen
</code></pre>
<p>ODer was ist mit boost::any?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904400</guid><dc:creator><![CDATA[Helium]]></dc:creator><pubDate>Mon, 31 Oct 2005 11:10:55 GMT</pubDate></item></channel></rss>