<?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[Klassen übergreifende Variablen erstellen]]></title><description><![CDATA[<p>Hallo leute,</p>
<p>kann mir bitte jemand sagen wie ich ein und die selbe variable (string) in mehreren klassen nutzen kann.</p>
<p>kurze simple beispiele wären echt nett.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/309244/klassen-übergreifende-variablen-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 11:18:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309244.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Oct 2012 08:03:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:03:45 GMT]]></title><description><![CDATA[<p>Hallo leute,</p>
<p>kann mir bitte jemand sagen wie ich ein und die selbe variable (string) in mehreren klassen nutzen kann.</p>
<p>kurze simple beispiele wären echt nett.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261561</guid><dc:creator><![CDATA[mittelzumzweck]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:03:45 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:10:01 GMT]]></title><description><![CDATA[<p>oder besser noch, wie kann ich in einer klasse, die variable der anderen klasse nutzen.</p>
<p>oder nein....</p>
<p>noch besser, wie kann ich eine variable, eines bereits erzeugten objektes in der cpp einer anderen klasse nutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261562</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261562</guid><dc:creator><![CDATA[mittelzumzweck]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:10:01 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:13:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class A
{
private:
	string&amp; s;
public:
	A(string&amp; s) : s(s) {}
};

class B
{
private:
	string&amp; s;
public:
	B(string&amp; s) : s(s) {}
};

int main()
{
	string s = &quot;Scherz&quot;;
	A a(s);
	B b(s);
}
</code></pre>
<p>Frage nochmal überdenken?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261563</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:13:52 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:16:34 GMT]]></title><description><![CDATA[<p>mittelzumzweck schrieb:</p>
<blockquote>
<p>noch besser, wie kann ich eine variable, eines bereits erzeugten objektes in der cpp einer anderen klasse nutzen.</p>
</blockquote>
<p>Auch das ergibt keinen Sinn. Hast du kein kleines Codebeispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261564</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:16:34 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:29:34 GMT]]></title><description><![CDATA[<p>klar ich machs mal genauer.</p>
<p>klasse1:</p>
<p>erstellt ordner</p>
<p>hier ein teilausschnitt</p>
<pre><code>{
            cout &lt;&lt; &quot;welche version von Firefox soll installiert werden? \nSyntax beachten Bsp. fuer Firefox 5.0.1 \&quot; 5_0_1 \&quot;&quot; &lt;&lt; endl;
            cin  &gt;&gt; ver;
            instpath=&quot;mkdir c:\\repository\\install\\ff&quot;;
            merge_str= instpath+=ver;
            system(merge_str.c_str());

            createi();
            startin();
        }
</code></pre>
<p>dann wird dort eine firefox vers installiert.</p>
<p>klasse2:</p>
<p>in der anderen klasse soll eine INI datei erstellt werden.<br />
in dieser inidatei soll nun die zeile<br />
InstallDirectoryPath=C:\repository\install\ff&quot;hier soll dann die ver variable rein&quot;</p>
<p>so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261566</guid><dc:creator><![CDATA[mittelzumzweck]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:35:22 GMT]]></title><description><![CDATA[<p>mom ich gib lieber mal doch das code bsp.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261568</guid><dc:creator><![CDATA[mittelzumzweck]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:35:22 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 08:49:27 GMT]]></title><description><![CDATA[<p>fxinstaller</p>
<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;cstdlib&gt;
#include &lt;stdio.h&gt;
#include &quot;fxinstaller.h&quot;

using namespace std;

        FXINST::FXINST()
        {
            cout &lt;&lt; &quot;welche version von Firefox soll installiert werden? \nSyntax beachten Bsp. fuer Firefox 5.0.1 \&quot; 5_0_1 \&quot;&quot; &lt;&lt; endl;
            cin  &gt;&gt; ver;
            instpath=&quot;mkdir c:\\repository\\install\\ff&quot;;
            merge_str= instpath+=ver;
            system(merge_str.c_str());

            createi();
            startin();
        }
        /////////////////////////////////////////////////////////////////////////////////////

        void FXINST::createi()
        {
            ofstream installer (&quot;c:\\repository\\scripts\\fxinstall.bat &quot;);
                if(installer.is_open())
                    {
                        installer &lt;&lt; &quot;cd ..&quot; &lt;&lt; endl;
                        installer &lt;&lt; &quot;cd ..&quot; &lt;&lt; endl;
                        installer &lt;&lt; &quot;cd ..&quot; &lt;&lt; endl;
                        installer &lt;&lt; &quot;cd c:\\repository\\ffrep&quot;&lt;&lt; endl;
                        installer &lt;&lt; &quot;start /wait firefoxsetup&quot; &lt;&lt; ver &lt;&lt;&quot;.exe -ms /INI=C:\\repository\\scripts\\fx.ini&quot; &lt;&lt; endl;
                        installer.close();
                    }
                else
                    {
                        cout &lt;&lt;&quot;Datei Konnte nicht geoeffnet werden.&quot;;
                    }
        }
        void FXINST::startin()
        {
            system(&quot;start c:\\repository\\scripts\\fxinstall.bat&quot;);
        }
</code></pre>
<p>inicreator</p>
<pre><code>#include &quot;fxiniscript&quot;

using namespace std;

        FXINI::FXINI()
        {
            createi();
        }
        void FXINI::createi()
        {
            ofstream installer (&quot;c:\\repository\\scripts\\fxini.ini &quot;);
                if(installer.is_open())
                    {
                        installer &lt;&lt; &quot;[Install]&quot; &lt;&lt; endl;
                        installer &lt;&lt; &quot;InstallDirectoryPath=C:\\repository\\install\\ff&quot;&lt;&lt; endl;
                        installer &lt;&lt; &quot;InstallDirectoryName=Mozilla Firefox&quot; &lt;&lt; endl;
                        installer &lt;&lt; &quot;QuickLaunchShortcut=false&quot;&lt;&lt; endl;
                        installer &lt;&lt; &quot;DesktopShortcut=false&quot;&lt;&lt; endl;
                        installer &lt;&lt; &quot;StartMenuShortcuts=false&quot;&lt;&lt; endl;
                        installer.close();
                    }
                else
                    {
                        cout &lt;&lt;&quot;Datei Konnte nicht geoeffnet werden.&quot;;
                    }
        }
</code></pre>
<p>so. und bei der erstellung der ini, soll in der zeile</p>
<pre><code>installer &lt;&lt; &quot;InstallDirectoryPath=C:\\repository\\install\\ff&quot;&lt;&lt; endl;
</code></pre>
<p>nun die selbe versionsnummer reinkommen, wie beim fxinstaller.</p>
<p>P.S die ganzen syntktischen fehler nicht beachten. habs nur eben dahingekrizelt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261569</guid><dc:creator><![CDATA[mittelzumzweck]]></dc:creator><pubDate>Thu, 18 Oct 2012 08:49:27 GMT</pubDate></item><item><title><![CDATA[Reply to Klassen übergreifende Variablen erstellen on Thu, 18 Oct 2012 11:05:41 GMT]]></title><description><![CDATA[<p>Entweder machst du <code>ver</code> in FXINST public oder</p>
<pre><code class="language-cpp">class FXINST
{
public:
    const auto&amp; version() { return ver; }
    ...
</code></pre>
<p>Edit: Um mich der Haftung für mit diesem Tipp verbundene mögliche Schäden zu entziehen, weise ich explizit darauf hin, dass die erste Option die schlechtere Wahl wäre.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261593</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261593</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Thu, 18 Oct 2012 11:05:41 GMT</pubDate></item></channel></rss>