Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi zusammen

hier erstmal etwas QT:

#include <iostream.h>

#include <conio.h>

class qm

{

float laenge, breite, ergebnis;

void calc ();

public:

qm(float l, float B);

qm(void);

void get ();

};

qm::qm(float lae=0, float bre=0)

{

laenge=lae;

breite=bre;

ergebnis=0;

}

qm::qm(void)

{

laenge=100;

breite=100;

ergebnis=0;

}

void qm::calc ()

{

ergebnis=laenge*breite;

}

void qm::get ()

{

qm::calc();

cout << endl << laenge << endl;

cout << endl << breite << endl;

cout << endl << ergebnis << endl;

}

int main ()

{

qm test;

test.get();

getch();

}

Nun ist mein Problem, dass sich der parameterlose Kosntruktor nicht mit meinem

Konstruktor mit Parameter verträgt. Wenn ich einen raus schmeisse dann tuts.

Oder kann ich Konstruktoren garnicht überladen ?

Fehlermeldung:

Ambiguity between qm::qm(float,float) and qm::qm()

Danke für Hilfe

cya

alligator

Die beiden Konstruktoren qm::qm(float,float) und qm::qm() sind auch ambiguous, da Du folgendes Konstrukt verwendest: qm::qm(float lae=0, float bre=0). Der Compiler kann in diesem Fall nicht entscheiden, welcher Constructor verwendet werden soll, da es zwei parameterlose gibt, die matchen.

Nic

  • Autor

Hi

hmm versteh ich nicht, denn qm::qm(float lae=0, float bre=0). ist doch nicht parmeterlos, sondern es wird nur ein Standardparameter gesetzt.

Aber recht hast du, dass es tut wenn ich =0 wegmachen ...

cya

alligator

Original geschrieben von alligator

Hi

hmm versteh ich nicht, denn qm::qm(float lae=0, float bre=0). ist doch nicht parmeterlos, sondern es wird nur ein Standardparameter gesetzt.

Aber recht hast du, dass es tut wenn ich =0 wegmachen ...

cya

alligator

ups text verschwunden, nochmal:

du hast schon recht, qm::qm(float lae=0, float bre=0) ist nicht parameterlos! Allerdings ist durch das setzen der Default-Werte auch der Aufruf ohne parameter legitim!!! Dies wiederspricht sich mit den Defaultkonstruktor!

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.