C++ Refresher

C++ Refresher - C++ Refresher CIS 554/1 C++ Standard...

Info iconThis preview shows pages 1–9. 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

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: C++ Refresher CIS 554/1 C++ Standard Library ● Set of standard C++ classes and functions which ANSI compliant compilers provide. ● ANSI - American National Standards Institute. An organization which develops standards for software languages. ● ANSI C Library Functions - the C++ standard library also contains a set of ANSI C functions which all ANSI standard compilers must provide (I.e to be ANSI compliant). ■ For example, memory operations like memcpy(), memset() and memcmp(). ■ Another example, string operations like strcat() and strcpy(). ● The C++ standard library is provided as part of the compiler. C++ Refresher CIS 554/2 C++ Standard Library (Cont.) ● Software Reuse - Most programs are made up of classes and functions you develop, classes and functions from the standard library, and classes and functions which other co-workers may have developed and made available to you. ● Programs also contain classes and functions from 3rd party vendors, which are extremely useful, but must be purchases seperately from the compiler. ■ Example - Rougue Wave is a set of stantard classes and templates which are widely used at Lockheed Martin. Rougue Wave can be purchases seperately, or comes as part of certain compilers. The HP/UX aCC compiler contains Rougue Wave as part of its bundle. C++ Refresher CIS 554/3 A Simple Program 1 // Fig. 1.2: fig1_02.cpp 2 // A first program in C++ 3 #include <iostream> 4 5 int main() 6 { // starts body of a function, program construct, or program scope 7 std::cout << "Welcome to C++!\n"; // output to screen 8 9 return 0; // indicate that program ended successfully 10 } // ends body of function, program construct, or program scope. C++ Refresher CIS 554/4 Output Escape Sequences ● The following are used with cout, inside the double quotes to help format the output. C++ Refresher CIS 554/5 Another Simple Program ● The following program using the “\n” Escape sequence to print the welcome on multiple lines. 1 // Fig. 1.5: fig1_05.cpp 2 // Printing multiple lines with a single statement 3 #include <iostream> 4 5 int main() 6 { 7 std::cout << "Welcome\nto\n\nC++!\n"; 8 9 return 0; // indicate that program ended successfully 10 } C++ Refresher CIS 554/6 Adding 2 Integers 1 // Fig. 1.6: fig1_06.cpp 2 // Addition program 3 #include <iostream> 4 5 int main() 6 { 7 int integer1, integer2, sum; // declaration 8 9 std::cout << "Enter first integer\n"; // prompt 10 std::cin >> integer1; // read an integer 11 std::cout << "Enter second integer\n"; // prompt 12 std::cin >> integer2; // read an integer 13 sum = integer1 + integer2; // assignment of sum 14 std::cout << "Sum is " << sum << endl; // print sum 15 16 return 0; // indicate that program ended successfully 17 } C++ Refresher CIS 554/7 Equality and Relational Operators C++ Refresher CIS 554/8 If Statement Example 1 // Fig. 1.14: fig1_14.cpp 2 // Using if statements, relational 3 // operators, and equality operators 4 #include <iostream> 5 6 using std::cout;...
View Full Document

This note was uploaded on 02/25/2011 for the course CIS 554 taught by Professor Staff during the Spring '08 term at Syracuse.

Page1 / 105

C++ Refresher - C++ Refresher CIS 554/1 C++ Standard...

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

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