# CS 376b Computer Vision

Size: px
Start display at page:

Transcription

1 CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann

2 Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++

3 Cross-correlation Cross-correlation involves aligning the origin of the mask with a pixel in question and multiplying the corresponding mask pixel values with the pixels in the original image and summing them all up. This summed up value is the value of the new pixel. No divide takes place. Typical masks though will either sum up to 0 or 1. A smoothing mask will sum up to 1. A derivative mask will sum up to 0. Concern: The result of the sum of the multiplications is not guaranteed to be within the range College - CS Fall 2014

4 Derivative and Smoothing masks Derivative masks values have opposite signs in order to obtain a high response in signal regions of high contrast sum of values is 0, so a 0 results from constant regions first derivative masks produce high abs values at points of high contrast second derivative masks produce zero-crossings at points of high contrast Smoothing masks values are positive and sum to 1, so resulting value is same as input in constant regions College - CS Fall 2014

5 Convolution Convolution is similar to cross-correlation except the upper-left value in the mask is multiplied by the lower-right value in the image neighborhood and so on until the lower-right value in the mask is multiplied by the upper-left value in the image. think of the mask being flipped along the horizontal axis and then again along the vertical axis AND THEN doing cross-correlation with the flipped mask picture on the board If the mask is symmetrical both vertically and horizontally, then crosscorrelation and convolution yield the same result. The two terms are often confused and sometimes used interchangeably (incorrectly.) College - CS Fall 2014

6 Considerations resulting value of output image pixels can be much larger than the input image pixels due to the summation, it is also possible for the output image pixels to yield negative values if the mask contains negatives --- so the type of the new image needs to be considered as possibly being different than the input image type College - CS Fall 2014

7 Computational considerations consider the computation involved in convolution or cross-correlation if mask is size n x n, then for each pixel in the input image, we do n 2 multiplies and n 2-1 additions. if a mask is separable into two vectors that, when we take the outer product of them (example on the board), we get the original mask then we can reduce the computational complexity by first convolving or correlating the image with the column vector and then the resulting image can be convolved or correlated with the row vector to get the output image (which would result in the same image as convolving or correlating the nxn mask with the original image). how many multiplies and additions now? College - CS Fall 2014

8 Computational considerations if a mask is separable into two vectors that, when we take the outer product of them, we get the original mask then we can reduce the computational complexity by first convolving or correlating the image with the column vector and then the resulting image can be convolved or correlated with the row vector to get the output image (which would result in the same image as convolving or correlating the nxn mask with the original image). how many multiplies and additions now? (2n multiplies and 2(n-1) additions) per pixel College - CS Fall 2014

9 Smoothing examples College - CS Fall 2014

10 Smoothing examples College - CS Fall 2014

11 Smoothing examples College - CS Fall 2014

12 Estimating the gradient Often we want to find boundaries in images and know how sharp the boundaries are and in which direction the boundaries are. Given f(x,y) as our image function, we would like to compute the gradient at pixels [x,y]. The magnitude of the gradient will give us an indication of how sharp a boundary is, and the angle of the gradient will give us the direction. If we want to estimate the magnitude and direction of the gradient (where the maximum change occurs) do the following: the partial derivative of f w.r.t. x and the partial derivative of f w.r.t y make up the gradient. College - CS Fall 2014

13 Estimating the gradient The partial derivative of f w.r.t. x (f x ) and the partial derivative of f w.r.t y (f y ) make up the gradient. We can estimate these values in a discrete image at pixel x,y: for f x : take the difference between the pixel at x-1, y and x+1, y and divide by the change in x (2 pixels) for f y : take the difference between the pixel at x, y-1 and x, y+1 and divide by the change in y (2 pixels) We can get a better estimate if we average these calculations above and below and to the right and left of the pixel in question. Example on the board (figure 5.14) (draw triangle) The magnitude of the gradient is the square root of the sum of the squares of the partials The direction of the gradient is the angle which is arctan(f y / f x ) College - CS Fall 2014

14 Estimating the gradient These lead to the Prewitt masks The Sobel masks come from the same idea but with twice the weight given to the row/col the pixel is in. These masks are shown in figure 5.15 let me write them on the board and discuss College - CS Fall 2014

15 Now C++ College - CS Fall 2014

16 C++ C++ Bjarne Stroustrup (designer and 1 st implementer) designed to be fast object oriented C is almost a proper subset of C++ that is, a valid C program should typically be a valid C++ program

17 C++ vs. Java In C++ but not in Java can use pointers to memory locations have a pointer to a reference to an object that has been returned to the heap (destroyed) dangling pointer problem explicit programmer deallocation of memory allowed memory leaks no garbage collection array indices are not checked unpredictable behaviour when accessing array elements beyond end of array

18 C++ vs. Java In C++ but not in Java allow use of uninitialized variables (causes runtime error) allowed to not return a value from a non-void function can overload operators e.g. for a class I can overload the + operator to perform some operation on objects of that class. more flexible than requiring a function. can have global functions that are not part of any class

19 C++ vs. Java In C++ but not in Java has a preprocessor which can be used for (among other things) conditional compilation has the STL which contains things similar to what is found in Java Collections API has templates whereas Java uses generics for same purpose

20 C++ vs. Java c++ has fewer compile time checks (which generate errors) than Java c++ has fewer run time checks c++ has no standard GUI library c++ has fewer standard library functions vs. the large Java API c++ is not as portable as Java, but there are guidelines out there to which one should try to adhere for more portable c++

21 C++ from C There are programming features leftover from C that can be used in c++. c-style strings, c-style dynamic memory management, c-style printing, etc. we will look at the c-style way of doing things, but typically prefer the c++ way. we need to know the C ways because they are part of valid c++ programs and we need to be able to read code not written by us that may use the C style stuff and sometimes we might want to call a C function in some C library...

22 Some types C++ int, short, long float, double, long double any of the above numeric types can be prefaced with signed or unsigned char (typically 8 bits) wchar_t (wide = larger than a char) bool (0 = false, 1 = true) ints can be interpreted as bool (holdover from C which had no bool), 0=false, any other int is true. void enum (creates an integer type and named constants)

23 Some types C++ union union number { int x; double y; long double z; }; number num;

24 C++ // Hello.cpp #include <iostream> using namespace std; int main() { cout << "Hello, world!" << endl; return 0; }

25 C++ // #include logically inserts the code from the iostream file into this file // (Hello.cpp) // iostream is a system header file so we use the < > // if we wanted to include our own user-defined header file then we use " " // int main() is the function declaration (all programs need one main) // can take 2 arguments if defined with them (int argc, char **argv) // returns an int // cout is like System.out.println // << is an operator for writing // >> is an operator for reading // endl is a newline character

26 C++ // note: cout and endl are in the std namespace (like a package in java) // without using namespace std, we could: // std::cout << "Hello, world!" << std::endl;

27 C++ The C++ specification does not specify the exact sizes of the types therefore they are implementation dependent. If you want to know the size of a type on a particular system, you can use the sizeof operator in C++ to get this info. Let's see a program that uses this sizeof operator and prints the sizes of the various types. We write/edit/compile/run C++ programs with Eclipse, or we can use the command line like: g++ mycode.cpp -o mycode.o then to execute your program do:./mycode.o

28 C++ Like Java, C++ has for, while and do-while loops, C++ has if's and else's C++ has switch statements with cases C++ has same arithmetic operators C++ has same relational operators

29 C++ >> and << when used on ints do a shift. int x = 10; x = x << 2; // shift left by 2 bits multiplies by 4 cout << x << endl; // will be 40 >> is a shift right (divides by 2 * right operand) padding high bits with 0's?

30 More types C++ array similar to Java int nums[30]; // array of 30 ints, index starts at 0 int ages[] = {21, 18, 35, 52, 65}; can't put brackets before the name (but in Java can)

31 More types C++ objects a simple declaration in Java creates a reference to a class Card a; // a is a Card reference a simple declaration in C++ creates an object of that class by calling the default constructor string a; // actually calls string's default constructor string s1( Hello ); // calls a different constructor string s2 = string( Bye ); // also calls a constructor s1 = s2; // actually makes a COPY

32 More types C++ objects string s1( Hello ); // calls a different constructor string s2 = string( Bye ); // also calls a constructor s1 = s2; // actually makes a COPY s2 = So long ; // doesn't affect s1

33 More types C++ objects/references In Java we can have: Card a; // a reference to a Card (does NOT call Card's default constructor) Card b = new Card(2, 2); a = b; // a and b now both refer to the same object b.setrank(5); // the ONE object has rank 5 and both a and b refer to it This is the typical behaviour in Java (except for Strings where = actually makes a copy of the data not an alias.)

34 More types C++ objects/references In C++ we can have: Card &a; // a reference to Card (does NOT call Card's default constructor) Card b = new Card(2, 2); a = b; // a and b now both refer to the same object b.setrank(5); // the ONE object has rank 5 and both a and b refer to it see example programs

35 C++ a struct is a record in C++ and in C e.g. struct PhoneNumber { } int areacode; // first 3 digits, e.g. 518 int exchange; // next 3 digits e.g. 580 int last4; // last 4 digits e.g if you know structs from C, they are different in C++. In C++ they are essentially the same as classes except that by default a struct's members are public and by default a class's members are private.

36 classes in C++ C++ can have multiple inheritance typically divided into header and implementation (usually in different files) class definitions end with a semicolon divided into sections public: private: protected: inline functions - code in the definition header (interface) file vs. implementation file prototypes of functions and classes must appear before use extern destructors should have a default constructor and a copy constructor

### Short Notes of CS201

#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

### CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

### Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

### Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

### CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

### Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

CSCI 334: Principles of Programming Languages Lecture 18: C/C++ Homework help session will be tomorrow from 7-9pm in Schow 030A instead of on Thursday. Instructor: Dan Barowy HW6 and HW7 solutions We only

### Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

### 6.096 Introduction to C++ January (IAP) 2009

MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

### COMP322 - Introduction to C++ Lecture 01 - Introduction

COMP322 - Introduction to C++ Lecture 01 - Introduction Robert D. Vincent School of Computer Science 6 January 2010 What this course is Crash course in C++ Only 14 lectures Single-credit course What this

### Input And Output of C++

Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout

### AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

### Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

### Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

### CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

### CS

CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Programming in C++ First, some praise for C++ "It certainly has its good points. But by and large I think it s a bad language. It does a lot of things half well and

### Scientific Computing

Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course

### 1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity

### CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++

CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many

Your first C++ program #include using namespace std; int main () cout

### Professor Terje Haukaas University of British Columbia, Vancouver C++ Programming

C++ Programming C++ code is essentially a collection of statements terminated by a semicolon, such as (spaces not needed): a = b + c; Most C++ code is organized into header files and cpp files, i.e., C++

### Cours de C++ Introduction

Cours de C++ Introduction Cécile Braunstein cecile.braunstein@lip6.fr Cours de C++ 1 / 20 Généralité Notes Interros cours 1/3 Contrôle TP 1/3 Mini-projet 1/3 Bonus (Note de Participation) jusqu à 2 points

### UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . \$, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

### Introduction to Programming

Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

### A brief introduction to C++

A brief introduction to C++ Rupert Nash r.nash@epcc.ed.ac.uk 13 June 2018 1 References Bjarne Stroustrup, Programming: Principles and Practice Using C++ (2nd Ed.). Assumes very little but it s long Bjarne

### Outline. 1 About the course

Outline EDAF50 C++ Programming 1. Introduction 1 About the course Sven Gestegård Robertz Computer Science, LTH 2018 2 Presentation of C++ History Introduction Data types and variables 1. Introduction 2/1

### CS201 Some Important Definitions

CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

### STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

### Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

### C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

### CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 19 Introduction ti to C++ C++ C++ is an enormous language: g All of C Classes and objects (kind of like Java, some crucial differences)

### CSE 303: Concepts and Tools for Software Development

CSE 303: Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 24 Introduction to C++ CSE303 Autumn 2008, Lecture 24 1 C++ C++ is an enormous language: All of C Classes and objects

### Lab 1: First Steps in C++ - Eclipse

Lab 1: First Steps in C++ - Eclipse Step Zero: Select workspace 1. Upon launching eclipse, we are ask to chose a workspace: 2. We select a new workspace directory (e.g., C:\Courses ): 3. We accept the

### Object Oriented Design

Object Oriented Design Lecture 3: Introduction to C++ (Continue) Examples using declarations that eliminate the need to repeat the std:: prefix 1 Examples using namespace std; enables a program to use

### Variables. Data Types.

Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

### Object Reference and Memory Allocation. Questions:

Object Reference and Memory Allocation Questions: 1 1. What is the difference between the following declarations? const T* p; T* const p = new T(..constructor args..); 2 2. Is the following C++ syntax

### Computer Programming : C++

The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

### 377 Student Guide to C++

377 Student Guide to C++ c Mark Corner January 21, 2004 1 Introduction In this course you will be using the C++ language to complete several programming assignments. Up to this point we have only provided

### Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

### cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers.

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... today: language basics: identifiers, data types, operators, type conversions, branching and looping, program structure

### Interview Questions of C++

Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

### C++ Basics. Brian A. Malloy. References Data Expressions Control Structures Functions. Slide 1 of 24. Go Back. Full Screen. Quit.

C++ Basics January 19, 2012 Brian A. Malloy Slide 1 of 24 1. Many find Deitel quintessentially readable; most find Stroustrup inscrutable and overbearing: Slide 2 of 24 1.1. Meyers Texts Two excellent

### Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is

### 10. Functions (Part 2)

10.1 Overloaded functions 10. Functions (Part 2) In C++, two different functions can have the same name if their parameters are different; either because they have a different number of parameters, or

### CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

### CS201- Introduction to Programming Current Quizzes

CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements

### ANSI C. Data Analysis in Geophysics Demián D. Gómez November 2013

ANSI C Data Analysis in Geophysics Demián D. Gómez November 2013 ANSI C Standards published by the American National Standards Institute (1983-1989). Initially developed by Dennis Ritchie between 1969

### Chapter 2. Procedural Programming

Chapter 2 Procedural Programming 2: Preview Basic concepts that are similar in both Java and C++, including: standard data types control structures I/O functions Dynamic memory management, and some basic

### UEE1302 (1102) F10: Introduction to Computers and Programming

Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad Outline 1. Introduction to C++ Programming 2. Comment 3. Variables and Constants 4. Basic C++ Data Types 5. Simple Program: Printing

### CS 11 C++ track: lecture 1

CS 11 C++ track: lecture 1 Administrivia Need a CS cluster account http://www.cs.caltech.edu/cgi-bin/ sysadmin/account_request.cgi Need to know UNIX (Linux) www.its.caltech.edu/its/facilities/labsclusters/

### Assumptions. History

Assumptions A Brief Introduction to Java for C++ Programmers: Part 1 ENGI 5895: Software Design Faculty of Engineering & Applied Science Memorial University of Newfoundland You already know C++ You understand

### (5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University

(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University Key Concepts 2 Object-Oriented Design Object-Oriented Programming

### the gamedesigninitiative at cornell university Lecture 7 C++ Overview

Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on

### III. Classes (Chap. 3)

III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,

### Type Aliases. Examples: using newtype = existingtype; // C++11 typedef existingtype newtype; // equivalent, still works

Type Aliases A name may be defined as a synonym for an existing type name. Traditionally, typedef is used for this purpose. In the new standard, an alias declaration can also be used C++11.Thetwoformsareequivalent.

### CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library

### Introducing C++ to Java Programmers

Introducing C++ to Java Programmers by Kip Irvine updated 2/27/2003 1 Philosophy of C++ Bjarne Stroustrup invented C++ in the early 1980's at Bell Laboratories First called "C with classes" Design Goals:

### CS201 Latest Solved MCQs

Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

### Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes

Distributed Real-Time Control Systems Lecture 17 C++ Programming Intro to C++ Objects and Classes 1 Bibliography Classical References Covers C++ 11 2 What is C++? A computer language with object oriented

### Java Basic Syntax. Java vs C++ Wojciech Frohmberg / OOP Laboratory. Poznan University of Technology

Java vs C++ 1 1 Department of Computer Science Poznan University of Technology 2012.10.07 / OOP Laboratory Outline 1 2 3 Outline 1 2 3 Outline 1 2 3 Tabular comparizon C++ Java Paradigm Procedural/Object-oriented

### A First Program - Greeting.cpp

C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

### Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

### CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

### Introduction to Programming using C++

Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know

### Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O

Outline EDAF30 Programming in C++ 2. Introduction. More on function calls and types. Sven Gestegård Robertz Computer Science, LTH 2018 1 Function calls and parameter passing 2 Pointers, arrays, and references

### CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings

CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings 19/10/2017 CE221 Part 2 1 Variables and References 1 In Java a variable of primitive type is associated with a memory location

### C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

### Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja

### CSCI-1200 Data Structures Fall 2017 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

CSCI-1200 Data Structures Fall 2017 Lecture 5 Pointers, Arrays, & Pointer Arithmetic Review from Letctures 3 & 4 C++ class syntax, designing classes, classes vs. structs; Passing comparison functions to

### A506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each).

A506 / C201 Computer Programming II Placement Exam Sample Questions For each of the following, choose the most appropriate answer (2pts each). 1. Which of the following functions is causing a temporary

### Lecture 15a Persistent Memory & Shared Pointers

Lecture 15a Persistent Memory & Shared Pointers Dec. 5 th, 2017 Jack Applin, Guest Lecturer 2017-12-04 CS253 Fall 2017 Jack Applin & Bruce Draper 1 Announcements PA9 is due today Recitation : extra help

### CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

CSC 126 FINAL EXAMINATION Spring 2011 Version A Name (Last, First) Your Instructor Question # Total Possible 1. 10 Total Received 2. 15 3. 15 4. 10 5. 10 6. 10 7. 10 8. 20 TOTAL 100 Name: Sp 11 Page 2

### Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

### CS 61C: Great Ideas in Computer Architecture Introduction to C

CS 61C: Great Ideas in Computer Architecture Introduction to C Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda C vs. Java vs. Python Quick Start Introduction

### Introduction to C++ Introduction to C++ 1

1 What Is C++? (Mostly) an extension of C to include: Classes Templates Inheritance and Multiple Inheritance Function and Operator Overloading New (and better) Standard Library References and Reference

### Lecture 2, September 4

Lecture 2, September 4 Intro to C/C++ Instructor: Prashant Shenoy, TA: Shashi Singh 1 Introduction C++ is an object-oriented language and is one of the most frequently used languages for development due

### Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

### C Introduction. Comparison w/ Java, Memory Model, and Pointers

CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

### Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

### Reliable C++ development - session 1: From C to C++ (and some C++ features)

Reliable C++ development - session 1: From C to C++ (and some C++ features) Thibault CHOLEZ - thibault.cholez@loria.fr TELECOM Nancy - Université de Lorraine LORIA - INRIA Nancy Grand-Est From Nicolas

### COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

### Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

### CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,

### CS250 Final Review Questions

CS250 Final Review Questions The following is a list of review questions that you can use to study for the final. I would first make sure you review all previous exams and make sure you fully understand

### UNIT-2 Introduction to C++

UNIT-2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some

### Computer Science II Lecture 1 Introduction and Background

Computer Science II Lecture 1 Introduction and Background Discussion of Syllabus Instructor, TAs, office hours Course web site, http://www.cs.rpi.edu/courses/fall04/cs2, will be up soon Course emphasis,

### CSC1322 Object-Oriented Programming Concepts

CSC1322 Object-Oriented Programming Concepts Instructor: Yukong Zhang February 18, 2016 Fundamental Concepts: The following is a summary of the fundamental concepts of object-oriented programming in C++.

### Homework #3 CS2255 Fall 2012

Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation

### Tokens, Expressions and Control Structures

3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

### Multimedia-Programmierung Übung 3

Multimedia-Programmierung Übung 3 Ludwig-Maximilians-Universität München Sommersemester 2016 Ludwig-Maximilians-Universität München Multimedia-Programmierung 1-1 Today Ludwig-Maximilians-Universität München

### The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

### C++ Programming for Non-C Programmers. Supplement

C++ Programming for Non-C Programmers Supplement ii C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by itcourseware, 10333 E. Dry Creek Rd., Suite 150, Englewood,

### Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance

### Functions, Arrays & Structs

Functions, Arrays & Structs Unit 1 Chapters 6-7, 11 Function Definitions! Function definition pattern: datatype identifier (parameter1, parameter2,...) { statements... Where a parameter is: datatype identifier

### More About Classes. Gaddis Ch. 14, CS 2308 :: Fall 2015 Molly O'Neil

More About Classes Gaddis Ch. 14, 13.3 CS 2308 :: Fall 2015 Molly O'Neil Pointers to Objects Just like pointers to structures, we can define pointers to objects Time t1(12, 20, true); Time *tptr; tptr

### What will happen if we try to compile, link and run this program? Do you have any comments to the code?

1 # include < iostream > 2 3 int main () 4 { 5 std :: cout

### CS2255 HOMEWORK #1 Fall 2012

CS55 HOMEWORK #1 Fall 01 1.What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y; a. 10 b. 7 c. The