Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 4 fuera de 96 páginas
Examen

Solution Manual For Concepts of Programming Languages 11th Edition by Robert Sebesta

Document preview thumbnail
Vista previa 4 fuera de 96 páginas

Solution Manual For Concepts of Programming Languages 11th Edition by Robert Sebesta

Vista previa del contenido

Object-Orientedg Programmingg (CSC221)
Introduction

Whatg isg OOP
• Ing simpleg term,g OOPg isg programmingg withg objects.
• Objects
o Objectsg areg theg evolutionaryg extensiong ofg theg conceptg ofg recordsg thatge
nablegusgtogorganizegdatagintogpackages.
o Itg allowg usg tog combineg bothg datag andg codeg intog ag singleg package.
o Therefore,g ang objectg isg ag languageg constructg thatg tiesg datag withg theg functionsg
thatgoperatesgongthegdata.


OOPg viewpoint

Lowglevelg object




Windowg object FilegManagement
gobject




Wordgprocessing Editinggobject
gApplication




Keyboardgcontrol
gobject




Theg figureg aboveg showg howg tog createg ag setg ofg objectsg forg ag wordg processorg application.

• Theg arrangementg isg dividedg intog objectsg suchg asg lowg levelg object,g windowg
object,gfilegmanagementgobjectsgetc.


Advantages
- Majorg operationg ofg ag programg cang easilyg beg isolated.
- Someg objectsg areg usedg tog createg otherg objects.
- Thisg helpsg tog hideg theg detailsg ofg theg lowerg levelg objects.


Traditional programming vs OOP
g g g

- Ing traditionalg view,g functionsg areg theg mostg important,g i.e.g allg theg codeg ing ag programg i
sgdesignedgaroundgthegfunctions.
- Ing theg OOPg view,g objectsg areg theg mostg important,g programsg areg designedg aroundg objects,
gfunctionsgaregsecondary




7

,- Thisgrolegrevealsgingthegwaygobjectsgaregused,grathergthangpassinggobjects(data)gtogfun
ctions,gobjectsgaregusedgtogcallgfunctions.
- Programsgcangavoidglargegfunctionsgthatgcontainglogicgforgmultiplegcases,ginsteadgmulti
plegobjectsgaregcreatedgtogrepresentgthegdifferentglogicalgcomponentsgofgagprogram.

Componentsg ofg OOP
• Classes
• Objects
• Instanceg variables
• Methods


Classes and objects
g g




- Ag classg isg ang abstractg definitiong ofg ang object
o Itg definesg theg structureg andg behaviourg ofg eachg objectg ing theg class.
o Itg servesg asg ag templateg forg creatingg objects

- objectsg mayg beg groupedg intog classes
o Ag particularg objectg ofg ag classg isg ang instance.

- Theg figureg belowg illustrate:



Classg =g typegdefinitiongObj
ectg=gvariablegofgagclass.

1.exe




- Ag classg containg twog typesg ofg components
o Instanceg variables
o g Methods
1.exe




- Instanceg variablesg defineg theg internalg datag stateg ofg ang object
- Methodsg defineg ang object‟sg behavior,g thatg isg theg actionsg thatg theg objectg can
perform.

Sampleg class

• Class

Properties Course Behaviour

Name Addg ag student
Location Deleteg ag student
Daysg offered Getg courseg roster
Creditg hours ….
Startg time e.t.c




8

,Endg time



Theg threeg faces(properties)g ofg OOP

WhengprogramminggwithgC++g„sgobjectgorientedg features,g thereg areg threeg underlyinggp
ropertiesgthatgsurfacegagaingandgagain:
• Encapsulation
• Polymorphism
• Inheritance

Encapsulation
- Encapsulationg isg thegtechniqueg ofg combiningg datag andg theg operationsg neededg tog
processgthegdatagundergonegpackage[object].
- Itg isg whatg givesg objectsg theirg buildingg blockg flavor.
- Encapsulationg providesg twog importantg features:
o Putsg datag andg functionsg underg oneg roof.
o Providesg datag hidingg capabilities.




Polymorphism
- Polymorphismgisg theg qualitygthatgallowsg oneg nameg togbeg usedg forgtwogorgmoreg relatedg butg
technicallygdifferentgpurposes.

- Polymorphismg allowsg oneg nameg tog specifyg ag generalg classg ofg actions.g Withing ag general
gclassg ofg actions,g theg specificg actiongtog beg appliedg isgdeterminedg byg theg typeg ofg data.

Forgexample,gingC,gthegabsolutegvaluegactiongrequiresgthreegdistinctgfunctiongnames:gabs(g)gforginteger,glabs(g)gf
orglongginteger,gandgfabs(g)g forgfloating-
pointgvalue.gHowevergingC++,geachgfunctiongcangbegcalledgbygthegsamegname,gsuchgasgabs(g).gThegtypegofgdatag
usedgtogcallgthegfunctiongdeterminesgwhichgspecificgversiongofgthegfunctiongisgactuallygexecuted.

-
Ing C++g itg isg possibleg tog useg oneg functiong nameg forg manyg differentg purposes.g Thisg typ
eg ofgpolymorphismgisgcalledgfunctiongoverloading.

- Polymorphismgcangalsogbegappliedgtogoperators.gIngthatgcasegitgisgcalledgoperatorgoverloading.
- Theg abilityg tog hideg manyg differentg implementationsg behindg ag singleg interface.


Whatg isg ang interface?
- Ag namedg setg ofg operationsg thatg characterizeg theg behaviourg ofg ang element.
• Theg interfaceg formalizesg polymorphism

<<interface>>
Triangle
gPolygon

, 9

draw
Square

Libro relacionado
 image
Editorial: 2015 ISBN: 9780133943023 Edición: Desconocido

Información del documento

Subido en
26 de febrero de 2025
Número de páginas
96
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$21.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
GOLDENNTESTBANKS
4.7
(720)
Vendido
13
Seguidores
1
Artículos
460
Última venta
3 meses hace


Reseñas de compradores verificados




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes