Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Programm schreiben, brauch eure Hilfe

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: [ 1 ] [ 2 ] > 3 < [ 4 ]
020
09.07.2003, 17:58 Uhr
virtual
Sexiest Bit alive
(Operator)


Wenn Du Code postest, verwende bitte Code tags, macht uns die Arbeit leichter! Ich machs jetzt nochmal für Dich.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
021
09.07.2003, 18:01 Uhr
virtual
Sexiest Bit alive
(Operator)


Ich würde mal sagen, du mußt im header schreiben

C++:
class Bruch {
...
    Bruch(void);
    Bruch(int z,int n[b] = 1[/b]);
...


Also ein Defaultwert für n mitliefern.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)

Dieser Post wurde am 09.07.2003 um 18:01 Uhr von virtual editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
022
09.07.2003, 18:28 Uhr
~dj-union
Gast


Hi!

Also daran liegts net...hab ja 2 Konstruktoren...einer parameterlosen und einer mit Initialisierung...
Ich seh wohl den Wald vor lauter Bäumen nicht mehr...
Noch ne Idee???

Gruss, dj-union
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
023
09.07.2003, 19:41 Uhr
virtual
Sexiest Bit alive
(Operator)


Was ist denn die Fehlermeldung?
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
024
09.07.2003, 20:21 Uhr
~dj-union
Gast


Er meint Bruch wäre keine Klasse oder namespace vorhanden...und noch ein paar andere Fehler...
Ich blick jetzt überhaupt nix mehr...
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
025
12.07.2003, 10:11 Uhr
~dj-union
Gast


Hi Leute!

Mittlerweile bin ich ein bissl weiter was das Programm betrifft... Soweit bin ich:


C++:
#include <iostream>
#include <string>

using namespace std;

typedef string Exception;

class Bruch
{
friend ostream &operator <<(ostream &, const Bruch &);
friend Bruch operator *(int, const Bruch &);

public:
Bruch();
Bruch(int, int) throw(Exception);
Bruch(int);

protected:
int x, y;
};

Bruch::Bruch()
: x(1), y(1)
{
return;
};

Bruch::Bruch(int a, int b)
throw(Exception)
: x(a), y(b)
{
if (!b)
throw "Division durch Null";
return;
};

Bruch::Bruch(int a)
: x(a), y(1)
{
return;
};

ostream &operator <<(ostream &s, const Bruch &b)
{
s << b.x << "/" << b.y;
return s;
};

Bruch operator *(int i, const Bruch &b)
{
return Bruch(i * b.x, b.y);
};

int main()
{
Bruch b1(3,4);
Bruch b2;

b2 = 3 * b1; // 3/4 * 3 => Ausgabe: 9/4
cout << b2 << endl;

return 0;
}


Aber leider funktioniert das nicht, weil der <<-Operator laut Compiler mehrdeutig ist...Hat jemand eine Idee worans liegt?

Mfg, dj-union
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
026
12.07.2003, 10:31 Uhr
virtual
Sexiest Bit alive
(Operator)


Ich bekomme obigen Code problemlos durch den Compiler.

Kritikwürdig finde ich nach wie vor den op*, da fände ich ein

C++:
Bruch operator * (const Bruch& a, const Bruch& b)


besser, was ja auch nun problemlos funktionieren sollte, nachdem du einen Constructor Bruch(int) gebaut hast, so daß auch 3*b1 tun sollte.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
027
12.07.2003, 17:25 Uhr
~dj-union
Gast


Welche Version benutzt du? Ich hab Visual C++ 6.0....
Bei mir funktionierts nicht...

Stefan
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
028
12.07.2003, 18:29 Uhr
virtual
Sexiest Bit alive
(Operator)


Ich benutze den gcc 3.2.1. Sieht für mich nach einem VC Problem aus, denn selbst der standardkonformste Compiler den ich kenne, compilert den Code, wenngleich er sich über zuviele Semikolons beschwert (was aber nicht im Zusammenhang mit Deinem Problem stehen dürfte).
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)

Dieser Post wurde am 12.07.2003 um 18:35 Uhr von virtual editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
029
12.07.2003, 19:54 Uhr
Tommix



Hallo,
hab's eben durch Visual C++ 6 compilieren lassen - kein Fehler.
@Stefan: Hast Du das aktuelle Service Pack?

Gruss, Tommix

Edit: Service Pack 5:
http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.asp

Dieser Post wurde am 12.07.2003 um 20:06 Uhr von Tommix editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: [ 1 ] [ 2 ] > 3 < [ 4 ]     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: