<?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[Operatorüberladung - friend - error]]></title><description><![CDATA[<pre><code class="language-cpp">// HEADER
class Token
{
private:
  Type myType;
  std::string myValue;

public:
  Token(Type type = Token, const std::string&amp; value);

  friend bool operator==(Type type, const Token&amp; token);
};

// SOURCE
bool operator==(Type type, const Token&amp; token)
{
  return type == token.myType; // error: ‘Type Token::myType’ is private
}
</code></pre>
<p>Ich habs doch als friend deklariert? Warum dann <em>&quot;error: ‘Type Token::myType’ is private&quot;</em>?</p>
<p>Bin am Verzweifeln...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/270012/operatorüberladung-friend-error</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 19:02:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270012.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Jul 2010 12:23:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Operatorüberladung - friend - error on Mon, 05 Jul 2010 12:23:05 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// HEADER
class Token
{
private:
  Type myType;
  std::string myValue;

public:
  Token(Type type = Token, const std::string&amp; value);

  friend bool operator==(Type type, const Token&amp; token);
};

// SOURCE
bool operator==(Type type, const Token&amp; token)
{
  return type == token.myType; // error: ‘Type Token::myType’ is private
}
</code></pre>
<p>Ich habs doch als friend deklariert? Warum dann <em>&quot;error: ‘Type Token::myType’ is private&quot;</em>?</p>
<p>Bin am Verzweifeln...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1921597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1921597</guid><dc:creator><![CDATA[hmmm...]]></dc:creator><pubDate>Mon, 05 Jul 2010 12:23:05 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorüberladung - friend - error on Mon, 05 Jul 2010 12:30:32 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Bin mir wzar nicht sicher ob es hilft, aber kann es sein das du irgendwo doppelte Namen verwendest, wenn ich mir alleine dieses Stückchen anschau:</p>
<pre><code class="language-cpp">Token(Type type = Token, const std::string&amp; value);
</code></pre>
<p>Was ist hier das &quot;= Token&quot;? Bzw. welcher Datentyp ist Type? Enumeration?</p>
<p>Mfg marco</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1921604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1921604</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Mon, 05 Jul 2010 12:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorüberladung - friend - error on Mon, 05 Jul 2010 14:02:17 GMT]]></title><description><![CDATA[<p>Auch wenn ich das wegnehme, bleibt der Fehler bestehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1921671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1921671</guid><dc:creator><![CDATA[hmmm...]]></dc:creator><pubDate>Mon, 05 Jul 2010 14:02:17 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorüberladung - friend - error on Mon, 05 Jul 2010 16:42:25 GMT]]></title><description><![CDATA[<p>Zeig mal ein komplettes Beispiel!</p>
<p>Das hier kompiliert bei mir ohne Probleme (MSVC++2008)</p>
<pre><code class="language-cpp">typedef int Type;

// HEADER
class Token
{
private:
  Type myType;
  std::string myValue;
public:
  friend bool operator==(Type type, const Token&amp; token);
};

// SOURCE
bool operator==(Type type, const Token&amp; token)
{
  return type == token.myType; // error: ‘Type Token::myType’ is private
}

int main()
{
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1921786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1921786</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 05 Jul 2010 16:42:25 GMT</pubDate></item></channel></rss>