C++ language first designed or implemented In 1980 by Bjarne Stroustrup, from Bell labs. that would receive formally this name at the end of 1983.

Slides:



Advertisements
Similar presentations
Lecture 3 Some commonly used C programming tricks. The system command Project No. 1: A warm-up project.
Advertisements

Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
1.00 Lecture 37 A Brief Look at C++: A Guide to Reading C++ Programs.
1 C++Tutorial Rob Jagnow This tutorial will be best for students who have at least had some exposure to Java or another comparable programming language.
C Language.
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
Chapter 10.
CIS 101: Computer Programming and Problem Solving Lecture10 Usman Roshan Department of Computer Science NJIT.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction.
Chapter Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Advanced Programming in the UNIX Environment Hop Lee.
C++ fundamentals.
C++ Tutorial Rob Jagnow. Overview Pointers Arrays and strings Parameter passing Class basics Constructors & destructors Class Hierarchy Virtual Functions.
More Classes in C++ Bryce Boe 2012/08/20 CS32, Summer 2012 B.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
Review of C++ Programming Part II Sheng-Fang Huang.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Programming Languages and Paradigms Object-Oriented Programming.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
Introduction to C++ Systems Programming. Systems Programming: Introduction to C++ 2 Systems Programming: 2 Introduction to C++  Syntax differences between.
Programming Language C++ Xulong Peng CSC415 Programming Languages.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
Operator Overloading Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd September 2006.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
File IO and command line input CSE 2451 Rong Shi.
C ++ Basics by Bindra Shrestha sce.uhcl.edu/shresthab CSCI 3333 Data Structures.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Chapter 13 – C++ String Class. String objects u Do not need to specify size of string object –C++ keeps track of size of text –C++ expands memory region.
Chapter 9 Questions 1. What are the difference between constructors and member functions? 2. Design and implement a simple class as you want, with constructors.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
User defined functions
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 16: Introduction to C++
C++ for Java Programmers Chapter 2. Fundamental Daty Types Timothy Budd.
Programming Language Principles Lecture 30 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Object-Oriented Programming.
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
Classes - Intermediate
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Functions Chapter 5. Function A set of instructions that are designed to perform specific task. A complete and independent program. It is executed by.
Prepared by Andrew Jung. Contents A Simple program – C++ C++ Standard Library & Header files Inline Functions References and Reference Parameters Empty.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Chapter 15 - C++ As A "Better C"
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
User-Written Functions
Introduction to C++ Systems Programming.
Programming with ANSI C ++
Command Line Arguments
Command line arguments
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
Object-Oriented Programming Part 1
Object-Oriented Programming
Java Programming Language
C++ Tutorial Rob Jagnow
Chapter 15 - C++ As A "Better C"
Based on slides created by Bjarne Stroustrup & Tony Gaddis
Part 1- C++ Class Features
Functions Reasons Concepts Passing arguments to a function
ENERGY 211 / CME 211 Lecture 17 October 29, 2008.
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
Presentation transcript:

C++ language first designed or implemented In 1980 by Bjarne Stroustrup, from Bell labs. that would receive formally this name at the end of 1983

The design goals of C++ were the easier development of C programs and an improved support for programmers. The new fundamental concepts in C++ are: Objects which communicate through messages and which represent a model of the re al world through their relations. The class concept defines user specific data types, related operators, and access functions. The data encapsulation guarantees that private objects can exclusively be accessed through specified methods. Inheritance allows the specification of relations between classes in the sense of abstraction or specialization. Inheritance also helps to avoid multiple implementations. A strong type concept inhibits undesired side effects for implicit type conversions like in C. The programmer has to specify a type conversion explicitly in C++. Function and operator overloading allow to define existing functions for additional parameter types. The strong type concept allows a function call only with the parameter types defined for the function. Efficiency: except for virtual functions, the conceptual extensions in C++ do not cause any runtime delays compared to C. Even for heavily used virtual functions in class libraries there is only a small loss in efficiency.

Programming and Systax

The main function int main(int argc, char** argv); This is where your code begins execution Number of arguments Array of strings argv[0] is the program name argv[1] through argv[argc-1] are command-line input

Strings char myString[20]; strcpy(myString, "Hello World"); myString[0] = 'H'; myString[1] = 'i'; myString[2] = '\0'; printf("%s", myString); A string in C++ is an array of characters Strings are terminated with the NULL or '\0' character output: Hi

Parameter Passing int add(int a, int b) { return a+b; } int a, b, sum; sum = add(a, b); pass by value int add(int *a, int *b) { return *a + *b; } int a, b, sum; sum = add(&a, &b); pass by reference Make a local copy of a and b Pass pointers that reference a and b. Changes made to a or b will be reflected outside the add routine

Organizational Strategy image.h Header file: Class definition & function prototypes.C file: Full function definitions Main code: Function references image.C main.C void SetAllPixels(const Vec3f &color); void Image::SetAllPixels(const Vec3f &color) { for (int i = 0; i < width*height; i++) data[i] = color; } myImage.SetAllPixels(clearColor);

Constructors Image(int w, int h) { width = w; height = h; data = new Vec3f[w*h]; } Constructors can also take parameters

Passing Classes as Parameters bool IsImageGreen(Image img); If a class instance is passed by value, the copy constructor will be used to make a copy. Computationally expensive bool IsImageGreen(Image *img); It’s much faster to pass by reference: bool IsImageGreen(Image &img); or

The Copy Constructor Image(Image *img) { width = img->width; height = img->height; data = new Vec3f[width*height]; for (int i=0; i<width*height; i++) data[i] = img->data[i]; } Image(Image *img) { width = img->width; height = img->height; data = img->data; } A default copy constructor is created automatically, but it is often not what you want:

BY » Krithee Sirisith ID