Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

CO2402 Advanced Programming with C++ Lecture 9 Notes

Beoordeling
-
Verkocht
-
Pagina's
5
Geüpload op
05-08-2024
Geschreven in
2023/2024

This document contains the comprehensive notes from Lecture 9 of the CO2402 course on Advanced Programming with C++. The lecture focuses on advanced concepts of inheritance and function overriding, crucial elements in object-oriented programming. Key topics covered include polymorphism, virtual functions, abstract classes, and dynamic binding.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

CO2402: Advanced Programming
with C++ Lecture 9


Introduction to Inheritance and Function Overriding

1. Review of Inheritance

o Base Class: The original class from which others inherit.

o Derived Class: The class that inherits from the base class.

o Public inheritance allows the derived class to access public
and protected members of the base class.

2. Function Overriding

o Occurs when a derived class defines a function with the same
name and parameters as a function in its base class. This
allows the derived class to provide a specific implementation.

Example:




3. Calling Overridden Functions

, o The version of the function called depends on the type of
the object or pointer. For objects, the derived class's
version is called if the object is of the derived type.

Example:




The base class function can still be called using the scope
resolution operator.




Polymorphism

1. Concept and Importance

o Polymorphism allows objects of different classes to be treated
as objects of a common base class. It enables the invocation
of derived class methods through base class pointers or
references.

Example:




The output is "Message from base class" because the function
is bound at compile time based on the pointer type (CBase*).


2. Virtual Functions

o Virtual functions enable polymorphism by allowing derived
classes to override base class methods. The virtual keyword in
the base class function declaration signals the compiler to use
dynamic binding.




Example:

Geschreven voor

Instelling
Studie
Onbekend
Vak

Documentinformatie

Geüpload op
5 augustus 2024
Aantal pagina's
5
Geschreven in
2023/2024
Type
College aantekeningen
Docent(en)
Nicholas mitchell
Bevat
Alle colleges

Onderwerpen

€4,14
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF


Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
BpoBpo University of Central Lancashire Preston
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
311
Lid sinds
5 jaar
Aantal volgers
250
Documenten
78
Laatst verkocht
4 dagen geleden

3,7

73 beoordelingen

5
27
4
17
3
17
2
5
1
7

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen