Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
This chapter includes contents: Difference between Programming in C and C++, a simple program: adding two integers, C++ standard library, header files, references and reference parameters, function overloading, basic object-oriented concepts, | CSC141- Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 32 Thanks for Lecture Slides: C How to Program by Paul Deital & Harvey Deital 6Ed. http://www.deitel.com/Books/C/CHowtoProgram7e/tabid/3635/Default.aspx www.cis.upenn.edu/~matuszek/cit591-2003/./38-object-concepts 1 Difference between; Programming in C and C++ 2 C++ Improves on many of C's features Has object-oriented capabilities Increases software quality and reusability Developed by Bjarne Stroustrup at Bell Labs Called "C with classes" C++ (increment operator) - enhanced version of C Superset of C Can use a C++ compiler to compile C programs Gradually evolve the C programs to C++ 3 A Simple Program: Adding Two Integers File extensions C files: .c C++ files: .cpp (which we use), .cxx, .C (uppercase) Differences C++ allows you to "comment out" a line by preceding it with // For example: // text to ignore - input/output stream header file Return types - all functions must declare their return type C does not require it, but C++ does Variables in C++ can be defined almost anywhere In C, required to defined variables in a block, before any executable statements 4 A Simple Program: Adding Two Integers (II) Input/Output in C++ Performed with streams of characters Streams sent to input/output objects Output std::cout - standard output stream (connected to screen) > stream extraction operator ("get from") std::cin >> myVariable; Gets stream from keyboard and puts it into myVariable 5 A Simple Program: Adding Two Integers (III) std::endl "end line" Stream manipulator - prints a newline and flushes output buffer Some systems do not display output until "there is enough text to be worthwhile" std::endl forces text to be displayed using statements Allow us to remove the std:: prefix Discussed later . | CSC141- Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 32 Thanks for Lecture Slides: C How to Program by Paul Deital & Harvey Deital 6Ed. http://www.deitel.com/Books/C/CHowtoProgram7e/tabid/3635/Default.aspx www.cis.upenn.edu/~matuszek/cit591-2003/./38-object-concepts 1 Difference between; Programming in C and C++ 2 C++ Improves on many of C's features Has object-oriented capabilities Increases software quality and reusability Developed by Bjarne Stroustrup at Bell Labs Called "C with classes" C++ (increment operator) - enhanced version of C Superset of C Can use a C++ compiler to compile C programs Gradually evolve the C programs to C++ 3 A Simple Program: Adding Two Integers File extensions C files: .c C++ files: .cpp (which we use), .cxx, .C (uppercase) Differences C++ allows you to "comment out" a line by preceding it with // For example: // text to ignore - input/output stream header file Return types - all functions must declare .