Lecture Object oriented programming - Lecture No 26

18 23 0
Lecture Object oriented programming - Lecture No 26

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

The topics discussed in this chapter are: Object-oriented programming overview, UML class diagram, first OOP class, private and public access, driver class, reference variables and instantiation, calling a method, calling object.

CSC241: Object Oriented Programming Lecture No 26 Previous Lecture • Intro to Generic Programming Template Function template – single template argument Today’s Lecture • • Functional templates – Example program – multiple arguments – Macros vs template Class templates Example program • Write a program that can sort int, float, double, character type of array in ascending order and then display it Write a program Function Templates – Multiple Arguments • • • Suppose a function to search an array for a specific value This function takes three arguments: – two that are template arguments – one of a basic type Function returns the array index for that value if it finds it, or –1 if it can’t find it template int find(atype* array, atype value, int size) { for(int j=0; j

Ngày đăng: 20/09/2020, 13:30

Mục lục

  • Slide 1

  • Previous Lecture

  • Today’s Lecture

  • Example program

  • Function Templates – Multiple Arguments

  • Slide 6

  • Template Arguments Must Match

  • More Than One Template Argument

  • Why not marcos?

  • What type works?

  • Class templates

  • Stack class as template

  • Cont.

  • Slide 14

  • Class Name Depends on Context

  • Nontype Parameters for Class Templates

  • Default Types for Class Templates

  • explicit specialization

Tài liệu cùng người dùng

Tài liệu liên quan