01-Intro-and-cpp--DRAFT - 10/1/2010 1 Introduction to Data...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 10/1/2010 1 Introduction to Data Structures and Object-Oriented Programming with C++ 1 Data Structures circle5 Entities and operations on these entities circle5 These entities often constitute a common language and basic tools that facilitate the problem solving circle5 Implementation of these entities and operations circle5 Efficiency → Algorithm Analysis 2 10/1/2010 2 Data Structures circle5 Learning the abstract model circle5 How to implement circle5 How to use in a problem solution Programming in C++ circle5 C++ circle5 Improves on many of C's features circle5 Has object-oriented capabilities circle5 Increases software quality and reusability – Developed by Bjarne Stroustrup at Bell Labs circle5 Called "C with classes" circle5 C++ (increment operator) - enhanced version of C circle5 Superset of C circle5 Can use a C++ compiler to compile C programs circle5 Gradually evolve the C programs to C++ 4 10/1/2010 3 Object Oriented Programming circle5 Object: An instance circle5 Class: Blueprint of an object circle5 Attribute: Values/state of an object circle5 Method: Behaviors/ services of an object circle5 Data Abstraction: Define an object by its data and allowable operations: an abstract data type. circle5 Information hiding: Restrict access to data so that it can be manipulated only in authorized ways. Separate class declarations from implementation. circle5 Encapsulation: Bundle data and operations into one logical unit. circle5 Inheritance: Creating classes from other classes circle5 Polymorphism: Different types of objects responding to the same method with different behavior circle5 Overloading : Methods that have the same name but different signatures inside the same class circle5 Overriding : Subclass replaces the implementation of one or more of its parent's methods 5 C++ Techniques head2right Relevant techniques include: • C++ classes , with private and public members • Function and operator name overloading to give "natural" function calls • Templates to allow the same code to be used on a variety of different data types • A clean built-in I/O interface , which itself involves overloading the input and output operators 6 10/1/2010 4 A Basic C++ Program //my very first C++ program #include <iostream> #include <math.h> using namespace std sing namespace std; void main(){ float x; cout << "Enter a real number: " << endl; cin >> x; cout << "The square root of " << x << " is: " << sqrt(x) << endl; } 7 A Basic C++ Program //my second C++ program #include <iostream> using namespace std; int main(){ int a=23; int b=34; cout << "Enter two integers:" << endl; cin >> a >> b; cout << endl; cout << “a + b =“ << a+b << endl; return 0; } 8 10/1/2010 5 A Basic C++ Program //my third C++ program #include <iostream> #include <iomanip> using namespace std; int main(){ double a=15.2; double b=34.3434343; cout << fixed << showpoint; cout << setprecision(2); cout << setw(6) << a << endl; cout << setw(7) << b << endl; return 0; } 9 output: #15.20#15....
View Full Document

Page1 / 54

01-Intro-and-cpp--DRAFT - 10/1/2010 1 Introduction to Data...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online