Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Agenda.

Slides:



Advertisements
Presentaciones similares
Escuchamos 1 2 hablas 2 3 L o s R e c u a d r o s E s c o n d i d o s Yo/ tomar Ellas/ estudiar Nosotros/ escuchar Tú/ hablar Los Verbos AR.
Advertisements

Spanish One Language Objective: Topic: Class: Content Objective: Day one Language Objective: Topic: Class: Content Objective: Day One Present Tense: -ar.
You need to improve the way you write and think in Spanish - Time This is an interactive presentation. You need your work sheet, your pencil, and your.
You need to improve the way you write and think in Spanish – At what time? This is an interactive presentation. You need your worksheet, your pencil, and.
La hora. ¿Qué hora es? Son las ocho= Its 8 oclock Son las ocho= Its 8 oclock Son las cinco= It's 5 oclock Son las cinco= It's 5 oclock Son las seis=Its.
Las Palabras Interrogativas
Mr. Redaelli OnlineTaco.com. To Have - Tener Yo tengo – I have Tú tienes – You have (Informal) Usted tiene – You have (Formal) El tiene – He has Ella.
I can... Tell Time Talk about my schedule © rh09.
MEXICAN CUSTOMS UPDATE
Para Empezar Hoy es miércoles el cinco de diciembre Write the correct definite articles in the spaces below. ____ béisbol ____ pizza ____ jazz ____tenis.
Capítulo 2B Los verbos después de las preposiciones
Parte A (10 pts.) You will hear statements describing the pictures. Write the letter that corresponds to the picture that is described. Ejemplo: 1. ______.
Telling Time in Spanish Grammar Notes
¿Qué hora es?. Es la una. Son las tres. Son las once.
Subjunctive and Indefinite Entities Capítulo 13. The subjunctive with indefinite entities Adjectival clauses are used when an idea cannot be expressed.
Frases útiles. Necesitas tu agenda Firmo la agenda.
1 3 WAYS TO ASK A QUESTION 1.Add question marks to a statement. 2.Add a tag word to a statement. 3.Use a question word.
IR- to go voy vamos vas vais va van
You have already learned that ser and estar both mean to be but are used for different purposes. These charts summarize the key differences in usage between.
2003 HYPACK MAX Training Seminar1 Sample Case la Entrada manual de Datos de la Línea de la costa El Metodo de MANUAL –DIG Objectos –Boya (Roja)
In both English and Spanish, the verb to be (ser) and numbers are used to tell time. Copyright © 2008 Vista Higher Learning. All rights reserved.
Hagan Ahora ¿Qué te gusta hacer?.
Verbs like GUSTAR First here are our indirect object pronouns in Spanish, which we use with these type of verbs: me(me)nos (us) te(you) le (him/her/you.
A expresar los gustos e intereses Estas preguntas son buenos para conversar sobre lo que les gusta con sus compañeros What do you like? What do you love?
and Materiales Escolares Lapiz Boligrafo Cuaderno Libro: Expresate Annuncios: Projects will be graded as soon as I can get to them.
Hazlo ahorael 14 de mayo Objetivos: SWBAT recognize different Spanish-speaking countries & currencies. SWBAT understand currency conversion. Write 3 sentences.
Copyright © 2008 Vista Higher Learning. All rights reserved You have already learned that ser and estar both mean to be but are used for different.
Bell Dinger el 26 de octubre Complete the chart with the appropriate subject pronouns.
Repaso Breve. Two-Form Verbs In Spanish, some verbs have only two forms. I like to call these verbs two- form verbs. The most common two-form verb is.
El verbo gustar. The verb gustar is used to talk about things that you or someone else likes to do. Gustar translates to ____ is pleasing to me in English.
A Comer Vamos a Poner la Mesa.
más con la ropa y tener que el tiempo de la playa y de las montañas
The Future Tense. In the past…to the future In Spanish 1 and 2, we used an easy way to talk about the future tense… ¿recuerdas? IR + A + INFINITIVE voyvamos.
¿ Que día es hoy? Hoy es lunes ¿ Cual es la fecha de hoy? Hoy es el 26 de septiembre ¿ Cual es tu clase favorita? Mi clase favorita es… BELL RINGER.
1 Definite and Indefinite Articles Articles Definite and Indefinite Articles Articles.
Señora Johnson Tambien necesitas 5 separadores Chambas Apuntes Impresos Actividades Registros.
Clases Extendidas La clase extendida hereda los campos y métodos de la clase de la cual extiende. La clase original se conoce como superclase y la clase.
MI CIUDAD (insert name of city here) Nombre____________ Fecha______________.
Haz Ahora Is it masculine or feminine? Do you remember? Write the word with its masculine or feminine word for THE (el or la). 1. Libro8. Chica 2. Profesor9.
Gone Friday, Sept. 27? Please get the next 3 artistas in your notes. The next slide has general notes from the whiteboard and a hint for your Viva (online)
A partir del lenguaje C Entorno de programación Visual C++
Genéricos en Java Jaime Ramírez, Ángel Lucas González
UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO
Telling time in Spanish: Explanation Practice exercise index McCarron.
Tener los básicos. Tener = to have The verb tener is literally translated as “to have” but has many other uses as well—to tell how old someone is Tener.
THE VERB TENER Spanish 1- 9/23/13 Sra. Baldwin. TENER Tener is a verb that means “to have”. It has irregular forms (does not follow a pattern) and must.
Me llamo ________ Clase 10 NM La fecha es el 2 de febrero del 2012 Propósito # 28: ¿Cómo repasamos para el examen de la Unidad 7? Actividad Inicial: Escribe.
Articles, nouns and contractions oh my!. The POWER of the article THE 1. There are four ways to express THE in Spanish 2. The four ways are: El La Los.
1 Day 4- Present tense conjugations of Regular –AR verbs An Online Learning Module Adapted from PowerShow.com Los Verbos Regulares.
 Making complete sentences How to make complete sentences in Spanish. The following presentation is designed to help you learn how to do the following:
Please do the following: 1.Measure an arms length of yarn of the color you like and cut it. (arms length goes from finger tip of one had to fingertip of.
ASIG M METODOLOGÍA DE LA INVESTIGACIÓN CONTABLE SEM DOCENTE: ING./C.P. LUIS EDUARDO MALAGÓN VÉLEZ TITULO MONOGRAFÍA Autores Monografía.
Warm-up Label the body parts La cabeza Los ojos La nariz La boca El est’omago El brazo La mano El dedo La pierna El pie.
The Hand Graphic Organizer (Future and Conditional) Students will trace their hand in a paper. Write in the subject pronouns at the top of each finger.
1 Chapter 8 Scope Dale/Weems/Headington. 2 Tópicos del Capítulo 8 l Local Scope vs. Global Scope of an Identifier l Detailed Scope Rules to Determine.
Programación orientada a objetos
Programación III Clase 06 Funciones.
¿Qué hora es? Son las diez.
Instructions for using this template. Click on the point value you want and say the name of the food shown. Once you’ve gotten to the answer, click the.
Time Expression with Hacer Grammar Essential #106.
Informatic Topics M. Sc. Juan Carlos Olivares Rojas February, 2009.
Empleando apuntadores una función puede entregar múltiples resultados / /Esta función no funciona #include void intercambiaValores(float a, float b) {
INSERT THE TITLE OF YOUR PRESENTATION HERE FREE PPT TEMPLATES ALLPPT.com _ Free PowerPoint Templates, Diagrams and Charts.
© Copyright Showeet.com E XAMPLE 1 A BSTRACT 3D P APER I NFOGRAPHICS Your own text goes here.
Present Tense of –ar Verbs
Introducing the math power book!
INSERT THE TITLE OF YOUR PRESENTATION HERE FREE PPT TEMPLATES ALLPPT.com _ Free PowerPoint Templates, Diagrams and Charts.
INSERT THE TITLE OF YOUR PRESENTATION HERE FREE PPT TEMPLATES ALLPPT.com _ Free PowerPoint Templates, Diagrams and Charts.
Pero and sino Preview Pero and sino.
Demonstrative adjectives; adverbs of place
Transcripción de la presentación:

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Agenda C++ Polymorphism The Trick A Polymorphic Matrix Implementacion details Recipe Conclusions

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática C++ Polymorphism class Base { public: virtual void doIt()=0; }; // … Base boom; // Error | | error: cannot declare variable `boom' to be of type `Base' | | error: because the following virtual functions are abstract: | | error: virtual void Base::doIt()

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática template void funBase( X & obj ) { obj.setVal( 5 ); } class TheBase { protected: void setVal( int arg ); }; class Derived : public TheBase { public: void setVal( int arg ) { /*... */ } }; void call_ok() { Derived val; // ok val.setVal( 12 ); funBase( val ); }

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática |14| void call_error() { |15| TheBase val; // Error !!! |16| val.setVal( 12 ); |17| funBase( val ); |18| } | | In function `void call_error()': | 7| error: `void TheBase::setVal(int)' is protected |16| error: within this context | | In function `void funBase(X&) [with X = TheBase]': |17| instantiated from here | 7| error: `void TheBase::setVal(int)' is protected | 3| error: within this context

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática The Trick Declaring protected in the base class the method you want to be reimplemented in every derived class, you get support for the compiler to verify that in every derived class the correct specification and implementation has been used.

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática | Matrix_BASE<> | / \ | Matrix_Dense<> | | Matrix_Sparse<> | template class Matrix_BASE { public: typedef E value_type; E & operator() (unsigned, unsigned); friend Matrix_BASE operator+ ( const Matrix_BASE& A, const Matrix_BASE& B ); };

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática template bool isDiagonal( const Mat& M ) { if ( M.rows() != M.cols() ) { return false; } typename Mat::value_type ZERO = 0; for (unsigned i=1; i < M.rows(); i++) { for (unsigned j=0; j < i; j++) { if ( M(i,j) != ZERO ) { return false; } else if ( M(j,i) != ZERO ) { return false; } return true; }

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática /// A+B template inline MAT operator+ ( const Matrix_BASE & A, const MAT& B ) { MAT Res = *( (MAT*)(&A) ); add_Matrix(Res,B); return Res; } Avoid ambiguity conflict with other operator+()’s Requieres use of typecast upon usage Res = *( (MAT*)(&A) );

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática /// A+B template inline MAT operator+ ( const Matrix_BASE & A, const MAT& B ) { // MAT Res = *( (MAT*)(&A) ); MAT Res = *( reinterpret_cast ( const_cast< Matrix_BASE * > >(&A) ) ); add_Matrix(Res,B); return Res; } // reinterpret_cast<>() converts any pointer type to any // other pointer type, even of unrelated classes.

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Non Polymorphic Abstraction /// Res += M template void add_Matrix( MAT& Res, const MAT& M ) { for ( unsigned i=0 ; i<Res.rows() ; ++i ) { for ( unsigned j=0 ; j<Res.cols() ; ++j ) { Res.operator()(i,j) += M(i,j); } return; }

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Specific Implementation template void add_Matrix( Matrix_Dense & Res, const Matrix_Dense & M ) { T *pRes = Res.m_val; T *pM = & M.m_val[0]; T *pEND = & Res.m_val[M.m_cols * M.m_rows]; for ( ; pRes != pEND; ++pRes, ++pM ) { *pRes += *pM; } return; }

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Recipe Abstract methods are “protected” Do not include the abstract method implementation Leave constructors and destructor “public” Use friend functions to implement abstract methods Set<>(a,b) uses set_BASE<>(S,a,b) [S is (*this)] Keep abstract functions together Now your C++ Use

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Conclusions Abstract classes need not be polymorphic No virtual method costs have to be paid No pointer indirection for invoking virtual methods Different implementations for the same class can be used Use

Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Source Code ¡¡¡ Muchas Gracias !!!