<?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[error LNK2005: already defined]]></title><description><![CDATA[<p>Hi!<br />
Ich habe da ein Problem mit meiner Klasse und zwar bekomm ich beim Kompilieren folgende Fehler:</p>
<p><em>FriskyDlg.obj : error LNK2005: &quot;public: int __thiscall Cat::GetAge(void)&quot; (?GetAge@Cat@@QAEHXZ) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: int __thiscall Cat::GetWeight(void)&quot; (?GetWeight@Cat@@QAEHXZ) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: void __thiscall Cat::SetAge(int)&quot; (?SetAge@Cat@@QAEXH@Z) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: void __thiscall Cat::SetWeight(int)&quot; (?SetWeight@Cat@@QAEXH@Z) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;class Cat Frisky&quot; (?Frisky@@3VCat@@A) already defined in FriskyCat.obj<br />
Debug/Frisky.exe : fatal error LNK1169: one or more multiply defined symbols found</em></p>
<p>Mein Klassenheader heißt &quot;FriskyCat.h&quot;. Dort steht folgendes Drinn:</p>
<pre><code class="language-cpp">#ifndef FriskyCat_h
#define FriskyCat_h

class Cat
{
public:
    int GetAge();
    int GetWeight();

    void SetAge(int age) ;
    void SetWeight(int weight);

private:
    int itsAge;
    int itsWeight;
};

#endif
</code></pre>
<p>In der dazugehörigen &quot;Frisky.cpp&quot; steht:</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;FriskyCat.h&quot;

Cat Frisky;

int Cat::GetAge()
{
    return itsAge;
}

int Cat::GetWeight()
{
    return itsWeight;
}

void Cat::SetAge(int age)
{
    itsAge = age;
}

void Cat::SetWeight(int weight)
{
    itsWeight = weight;
}
</code></pre>
<p>Ich habe eine Dialogfeldbasierte MFC anwendung (FriskyDlg) in die ich die FriskyCat.cpp inkludiert habe.<br />
Mein Ziel ist es, das ich in der FriskyDlg.cpp mit GetAge() und GetWeight() auf das Alter und Gewicht der Katze zugreifen kann.</p>
<p>Ich bin mir ziemlich sicher, das ich alles nur einmal Definiert habe.<br />
Diese include-guards funktionieren bei mir auch nicht. Was mache ich falsch? Unter Dos funktioniert alles, nur mit MFC nicht???</p>
<p>Danke im Vorraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/6241/error-lnk2005-already-defined</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 06:24:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/6241.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Jun 2003 19:20:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error LNK2005: already defined on Wed, 18 Jun 2003 19:20:00 GMT]]></title><description><![CDATA[<p>Hi!<br />
Ich habe da ein Problem mit meiner Klasse und zwar bekomm ich beim Kompilieren folgende Fehler:</p>
<p><em>FriskyDlg.obj : error LNK2005: &quot;public: int __thiscall Cat::GetAge(void)&quot; (?GetAge@Cat@@QAEHXZ) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: int __thiscall Cat::GetWeight(void)&quot; (?GetWeight@Cat@@QAEHXZ) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: void __thiscall Cat::SetAge(int)&quot; (?SetAge@Cat@@QAEXH@Z) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;public: void __thiscall Cat::SetWeight(int)&quot; (?SetWeight@Cat@@QAEXH@Z) already defined in FriskyCat.obj<br />
FriskyDlg.obj : error LNK2005: &quot;class Cat Frisky&quot; (?Frisky@@3VCat@@A) already defined in FriskyCat.obj<br />
Debug/Frisky.exe : fatal error LNK1169: one or more multiply defined symbols found</em></p>
<p>Mein Klassenheader heißt &quot;FriskyCat.h&quot;. Dort steht folgendes Drinn:</p>
<pre><code class="language-cpp">#ifndef FriskyCat_h
#define FriskyCat_h

class Cat
{
public:
    int GetAge();
    int GetWeight();

    void SetAge(int age) ;
    void SetWeight(int weight);

private:
    int itsAge;
    int itsWeight;
};

#endif
</code></pre>
<p>In der dazugehörigen &quot;Frisky.cpp&quot; steht:</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;FriskyCat.h&quot;

Cat Frisky;

int Cat::GetAge()
{
    return itsAge;
}

int Cat::GetWeight()
{
    return itsWeight;
}

void Cat::SetAge(int age)
{
    itsAge = age;
}

void Cat::SetWeight(int weight)
{
    itsWeight = weight;
}
</code></pre>
<p>Ich habe eine Dialogfeldbasierte MFC anwendung (FriskyDlg) in die ich die FriskyCat.cpp inkludiert habe.<br />
Mein Ziel ist es, das ich in der FriskyDlg.cpp mit GetAge() und GetWeight() auf das Alter und Gewicht der Katze zugreifen kann.</p>
<p>Ich bin mir ziemlich sicher, das ich alles nur einmal Definiert habe.<br />
Diese include-guards funktionieren bei mir auch nicht. Was mache ich falsch? Unter Dos funktioniert alles, nur mit MFC nicht???</p>
<p>Danke im Vorraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30315</guid><dc:creator><![CDATA[Perner]]></dc:creator><pubDate>Wed, 18 Jun 2003 19:20:00 GMT</pubDate></item><item><title><![CDATA[Reply to error LNK2005: already defined on Wed, 18 Jun 2003 20:21:00 GMT]]></title><description><![CDATA[<p>FriskyCat.h statt FriskyCat.cpp einbinden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30316</guid><dc:creator><![CDATA[mandrill]]></dc:creator><pubDate>Wed, 18 Jun 2003 20:21:00 GMT</pubDate></item></channel></rss>