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.

diamantförmige Vererbung

Empfohlene Antworten

Veröffentlicht

Hallo,

weiß jemand, wie ich bei einer diamantförmigen Vererbung

A

/ \

B C

\ /

D

B und C dazu bringe, nicht den Default-Konstruktor von A aufzurufen? Geht das überhaupt?

Vielen Dank schon im Voraus

PP

Original erstellt von ParameterParser:

<STRONG>Hallo,

weiß jemand, wie ich bei einer diamantförmigen Vererbung

A

/ \

B C

\ /

D

B und C dazu bringe, nicht den Default-Konstruktor von A aufzurufen? Geht das überhaupt?

</STRONG>

Hallo PP,

ja, das geht. Du musst dazu in A einen anderen Ctor schreiben, den Du in B und C aufrufst. Der Aufruf erfolgt aber nicht im Anweisungsblock, sondern unterliegt der Chainingkette, die der Compiler anlegt, weil die Basisklasse vor der abgeleiteten Klasse bearbeitet wird. Darum muss das in einer Liste erfolgen, etwa so:

B :: B(int a, int B)

: A(a) // Basisklasse A mit a initialisieren

{

// Subklasse B mit b initialisieren

}

Uli

Hallo Uli,

danke für den Tipp!

Es funktioniert wunderbar!

Gruß

PP

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.