<?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[Hilfe bei einer Funktion]]></title><description><![CDATA[<p>Also ich hab hier mein erstes Programm mit Klassen geschrieben jetzt hab ich nur noch das Problem , dass ich einen Uhrenvergleich mittels Clock::operator== integrieren muss das war ja bei &lt; und &gt; noch leicht aber bei == weiß ich nit weiter kann mir da bitte wer helfen???</p>
<p>Mein Programm:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;vector&gt;

using namespace std;

class Clock {

public:
  // Konstruktoren
  Clock() : h(0), m(0), s(0) {}
  Clock(const Clock&amp; c) 
    : h(c.h), m(c.m), s(c.s) {}
  Clock(int hour, int min, int sec)
    : h(hour), m(min), s(sec) {}
  // Destruktor ( nichts zu tun ... )
  ~Clock() {}

  //  Zeitvergleich
  bool operator&lt; (const Clock&amp; c) const;
  bool operator&gt; (const Clock&amp; c) const;
  bool operator== (const Clock&amp; c) const;

  //  stelle Zeit ein
  void set(int hour, int min, int sec);
  //  gib Zeit aus
  void print() const
    { cout &lt;&lt; h &lt;&lt; &quot;:&quot; &lt;&lt; m &lt;&lt; &quot;:&quot; &lt;&lt; s &lt;&lt; endl; }

  friend ostream&amp; operator&lt;&lt; (ostream&amp;, const Clock&amp;);

private:  

  int h,m,s;

};

//  Initialisierung der Uhr
void Clock::set(int hour, int min, int sec)
{
   h=hour; m=min; s=sec;    
}

//  Uhrenvergleich &lt;
bool Clock::operator&lt; (const Clock&amp; c) const
{
   if (h!=c.h)
     return h&lt;c.h;
   else if (m!=c.m)
     return m&lt;c.m;
   else 
     return s&lt;c.s;
}

//  Uhrenvergleich &gt;
bool Clock::operator&gt; (const Clock&amp; c) const
{
   if (h!=c.h)
     return h&gt;c.h;
   else if (m!=c.m)
     return m&gt;c.m;
   else 
     return s&gt;c.s;
}

//  Ausgabe
ostream&amp; operator&lt;&lt; (ostream&amp; os, const Clock&amp; c)
{
  return os &lt;&lt; c.h &lt;&lt; &quot;:&quot; &lt;&lt; c.m &lt;&lt; &quot;:&quot; &lt;&lt; c.s;
}

int main()
{
  //  Uhrenbeispiele
  Clock c1,c2,c3(12,36,0),c4(c3);

  c1.set(12,3,0);
  c2.set(15,32,0);

  //  Zeitausgabe
  c1.print();
  c2.print();
  c3.print();
  c4.print();

  cout &lt;&lt; &quot;c1 ... &quot; &lt;&lt; c1 &lt;&lt; endl;
  cout &lt;&lt; &quot;c2 ... &quot; &lt;&lt; c2 &lt;&lt; endl;
  cout &lt;&lt; &quot;c3 ... &quot; &lt;&lt; c3 &lt;&lt; endl;
  cout &lt;&lt; &quot;c4 ... &quot; &lt;&lt; c4 &lt;&lt; endl;

  cout &lt;&lt; endl &lt;&lt; &quot;Press ENTER to continue...&quot; &lt;&lt; endl;   //  **
  cin.get();                                              //  **    
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/228682/hilfe-bei-einer-funktion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 11:31:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/228682.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Dec 2008 16:03:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe bei einer Funktion on Mon, 01 Dec 2008 16:03:54 GMT]]></title><description><![CDATA[<p>Also ich hab hier mein erstes Programm mit Klassen geschrieben jetzt hab ich nur noch das Problem , dass ich einen Uhrenvergleich mittels Clock::operator== integrieren muss das war ja bei &lt; und &gt; noch leicht aber bei == weiß ich nit weiter kann mir da bitte wer helfen???</p>
<p>Mein Programm:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;vector&gt;

using namespace std;

class Clock {

public:
  // Konstruktoren
  Clock() : h(0), m(0), s(0) {}
  Clock(const Clock&amp; c) 
    : h(c.h), m(c.m), s(c.s) {}
  Clock(int hour, int min, int sec)
    : h(hour), m(min), s(sec) {}
  // Destruktor ( nichts zu tun ... )
  ~Clock() {}

  //  Zeitvergleich
  bool operator&lt; (const Clock&amp; c) const;
  bool operator&gt; (const Clock&amp; c) const;
  bool operator== (const Clock&amp; c) const;

  //  stelle Zeit ein
  void set(int hour, int min, int sec);
  //  gib Zeit aus
  void print() const
    { cout &lt;&lt; h &lt;&lt; &quot;:&quot; &lt;&lt; m &lt;&lt; &quot;:&quot; &lt;&lt; s &lt;&lt; endl; }

  friend ostream&amp; operator&lt;&lt; (ostream&amp;, const Clock&amp;);

private:  

  int h,m,s;

};

//  Initialisierung der Uhr
void Clock::set(int hour, int min, int sec)
{
   h=hour; m=min; s=sec;    
}

//  Uhrenvergleich &lt;
bool Clock::operator&lt; (const Clock&amp; c) const
{
   if (h!=c.h)
     return h&lt;c.h;
   else if (m!=c.m)
     return m&lt;c.m;
   else 
     return s&lt;c.s;
}

//  Uhrenvergleich &gt;
bool Clock::operator&gt; (const Clock&amp; c) const
{
   if (h!=c.h)
     return h&gt;c.h;
   else if (m!=c.m)
     return m&gt;c.m;
   else 
     return s&gt;c.s;
}

//  Ausgabe
ostream&amp; operator&lt;&lt; (ostream&amp; os, const Clock&amp; c)
{
  return os &lt;&lt; c.h &lt;&lt; &quot;:&quot; &lt;&lt; c.m &lt;&lt; &quot;:&quot; &lt;&lt; c.s;
}

int main()
{
  //  Uhrenbeispiele
  Clock c1,c2,c3(12,36,0),c4(c3);

  c1.set(12,3,0);
  c2.set(15,32,0);

  //  Zeitausgabe
  c1.print();
  c2.print();
  c3.print();
  c4.print();

  cout &lt;&lt; &quot;c1 ... &quot; &lt;&lt; c1 &lt;&lt; endl;
  cout &lt;&lt; &quot;c2 ... &quot; &lt;&lt; c2 &lt;&lt; endl;
  cout &lt;&lt; &quot;c3 ... &quot; &lt;&lt; c3 &lt;&lt; endl;
  cout &lt;&lt; &quot;c4 ... &quot; &lt;&lt; c4 &lt;&lt; endl;

  cout &lt;&lt; endl &lt;&lt; &quot;Press ENTER to continue...&quot; &lt;&lt; endl;   //  **
  cin.get();                                              //  **    
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1623867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1623867</guid><dc:creator><![CDATA[Sandra1986]]></dc:creator><pubDate>Mon, 01 Dec 2008 16:03:54 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei einer Funktion on Mon, 01 Dec 2008 16:16:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool Clock::operator==(const Clock&amp; c) const
{
    return h==c.h &amp;&amp; m==c.m &amp;&amp; s==c.s;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1623873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1623873</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 01 Dec 2008 16:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei einer Funktion on Mon, 01 Dec 2008 21:22:36 GMT]]></title><description><![CDATA[<p>Wobei ich hier eher zu globalen Operatoren (ausserhalb der Klasse) greifen würde:</p>
<pre><code class="language-cpp">bool operator==(const Clock&amp; Left, const Clock&amp; Right);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1623993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1623993</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 01 Dec 2008 21:22:36 GMT</pubDate></item></channel></rss>