C++ Crash Course For CS184 Sp08 Trevor Standley. C++ Is ~(C+Java)/2 Comprises a combination of both high level and low level language features Developed.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

C++ Introduction.
For(int i = 1; i
C++ Language Fundamentals. 2 Contents 1. Introduction to C++ 2. Basic syntax rules 3. Declaring and using variables.
Computer Science 1620 Math Library. Remember this program? suppose that I invest $25000 into a mutual fund that returns 8% per year. Write a program to.
Introduction to C++ Programming. Brief Facts About C++ Evolved from C Designed and implemented by Bjarne Stroustrup at the Bell Labs in the early 1980s.
Chapter 16 Exception Handling. What is Exception Handling? A method of handling errors that informs the user of the problem and prevents the program from.
Vectors, lists and queues
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Template Implicit function overload. Function overload Function overload double ssqq(double & a, double & b) { return(a*b);} float ssqq(float & a, float.
Derived data types Dealing with data –Where the information is stored –What value is kept there –What kind of information is stored Address operator Pointers.
Exercise 2.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
第三次小考. #include using namespace std; int aaa(int *ib,int a1,int a2) { int u,v; int m=(a1+a2)/2; if(a1==a2)return ib[a1]; u=aaa(ib,a1,m); cout
Bjarne Stroustrup started work on C with Classes in 1979 at Bell Labs. In 1983 it was renamed C++.
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
C + 1 == C++ ce153c Introduction2programming © 2006 NematAllah Ahmadyan.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
CSE 332: Combining STL features Combining STL Features STL has containers, iterators, algorithms, and functors –With several to many different varieties.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
Bjarne Stroustrup began work on "C with Classes" in The idea of creating a new language originated from Stroustrup's experience in programming for.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
C++
By – Tanvir Alam.  This tutorial offers several things.  You’ll see some neat features of the language.  You’ll learn the right things to google. 
Programming Language C++ Xulong Peng CSC415 Programming Languages.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
Subject: Programming in C++ 1. LEARNING OUTCOME  At the end of this slide, student able to:  Know the brief history of C++.  Explore Microsoft Visual.
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.
1 Object-Oriented Programming Using C++ CLASS 1. 2 Review of Syllabus Catalog Description –An introduction to object oriented programming techniques using.
Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
Templates Mark Hennessy Dept Computer Scicene NUI Maynooth C++ Workshop 18 th – 22 nd September 2006.
First steps Jordi Cortadella Department of Computer Science.
C ++ Basics by Bindra Shrestha sce.uhcl.edu/shresthab CSCI 3333 Data Structures.
Operator Overloading. Introduction It is one of the important features of C++ language  Compile time polymorphism. Using overloading feature, we can.
Monday, Mar 31, 2003Kate Gregory with material from Deitel and Deitel Week 12 Labs 4 and 5 are back File IO Looking ahead to the final.
Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.
CSE 332: C++ template examples Concepts and Models Templates impose requirements on type parameters –Types that are plugged in must meet those requirements.
CS 11 C++ track: lecture 1 Administrivia Need a CS cluster account sysadmin/account_request.cgi Need to know UNIX (Linux)
Lecture 19 CIS 208 Wednesday, April 06, Welcome to C++ Basic program style and I/O Class Creation Templates.
1 IDLOOPC1998. Object-Oriented Programming Using C++ CLASS 1.
CS Computer Science I. BCPL was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of the.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 16: Introduction to C++
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Make Make is a system utility that automatically compiles your programs for you Make looks for a file named Makefile (or makefile) in the current directory.
CSE 332: C++ template examples Today: Using Class and Function Templates Two examples –Function template for printing different types –Class template for.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
Templates. C++ 2 Outline Function templates  Function template definition  Function template overloading Class templates  Class template definition.
Generic Programming and Library Design Brian Bartman
Software Engineering Algorithms, Compilers, & Lifecycle.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Week 13 - Friday.  What did we talk about last time?  Server communications on a socket  Function pointers.
Hello Educational presentation.
Introduction to Programming
CSE202 Object Oriented Programing
Eugene Hsu.
Object Oriented Programming Mansoor Ahmed Bughio
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.
Computer science By/ Midhat Mohiey. Introduction to Programming using C ++ 2.
Random Number Generation
Name: Rubaisha Rajpoot
Programming 1 (CS112) Dr. Mohamed Mostafa Zayed 1.
CSE Object Oriented Programing
CSE 303 Concepts and Tools for Software Development
Programming Paradigms
Introduction to Algorithms and Programming COMP151
Presentation transcript:

C++ Crash Course For CS184 Sp08 Trevor Standley

C++ Is ~(C+Java)/2 Comprises a combination of both high level and low level language features Developed in 1979 at Bell Labs as an enhancement to the C programming language Developed for backward compatibility with C First named, C with Classes Blazing fast, just like C. Direct access to RAM Classes, polymorphism, exception handling, strong typing, templates, operator overloading etc No memory management

Common Complaints C++ is not a high level language. Memory management… Yuck! I hear that its complicated, and messy. It was designed for compatibility with an ancient language, certainly the designers of modern languages could have done better without this restriction. I dont like C, why should I like C++? Who knows C++?

Hello World #include using namespace std; int main() { cout << Hello World << endl; return 0; }

Object vs Reference Consider the following: swap(int &a, int &b) { int t = a; a = b; b = t; }

Creating an Object C++ vector vec; vec.push_back(6); vector vec2 = vec; //deep copy vector *vec = new vector (); vec->push_back(6); vector *vec2 = vec; //shallow copy Java Vector vec = new Vector ();

classes

Inheritance

Operator Overloading

Default Class Pieces foo has a destructor ~foo(){} a copy constructor foo(const foo &f){x = f.x;} an assignment operator foo operator = (const foo &f) { x = f.x; } Possibly others

Templates

Memory Management Take a deep breath, you probably wont have to do any. C++ uses the Resource Acquisition Is Initialization paradigm Clean up after yourself.

Memory Management 2 Most memory is managed automatically when an object is initialized or goes out of scope The only exception is when the new operator is used. Standard libraries manage their own memory If you use new, use delete

The Syntax new returns a pointer to a location in memory where the requested object is int *x = new int[5]; // returns a pointer to memory where 5 ints are delete [] x; x = new vector2d(3,5) delete x;

Memory Management Example 1

Memory Management Example 2

The Standard Template Library C++ has multiple inheritance, which has little meaning in practice except that the STL is awesome! std::vector: include std::list: include std::string : include std::stringstream : include Etc.

More Information 2B 2B son_of_Java_and_C%2B%2B