Understanding C++ File Structure and Introduction to STL

c file structure and intro to the stl n.w
1 / 17
Embed
Share

"Explore the basics of C++ file structure, variable definitions, boolean expressions, standard loops, branching, function declarations, file types, header files usage, and more. Get insights into C++ programming concepts with clear examples and explanations."

  • C++
  • File Structure
  • STL
  • Coding Basics
  • Programming

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. C++ File Structure and Intro to the STL G Carl Evans

  2. C Variable Definitions int i = 0; double radius = 6.5; const double kPi = 3.14159; int students_per_lecture[] = {155,121}; char *program_name = argv[0]; std::vector<double> grade_cutoffs = {0.9,0.8,0.7}; Monster cs126_prof; Room dcl_1320;

  3. C++ Bool and Bool Experssion bool fundamental type this will hold either true or false true This has the value of 1 false This has the value of 0 A nonzero value will be coerced to true A zero value will be coerced to false

  4. Standard Loops in C++ while(boolexpr){ body } for(intitialize; boolexpr; reloop){ body } for(range_decl : range_expr){ body } do{ body }while(boolexpr)

  5. Standard Branching if(boolexpr) { } else if (boolexpr) { } else { }

  6. How hard was third code review assignment? A. Easy B. Moderate C. Challenging D. Unreasonable

  7. How long did third assignment take? A. Less than 3 hours B. 3 to 6 hours C. 6 to 9 hours D. 9 to 12 hours E. More than 12 hours

  8. C++ function definitions and declarations Function Declarations int TimesTwo(int x); Function Definitions int TimesTwo(int x) { return x * 2; }

  9. C++ File Stucture Two file types .cpp This is the file type that contains the definitions and code. .h This is the file type that contains declarations.

  10. Using header files #include <iostream> #include <vector> #include <stdlib.h> #include "libmult.h"

  11. Writing Header Files #ifndef LIBMULT_H #define LIBMULT_H //declarations here #endif

  12. C++ Strings C strings C++ being based on C supports C style strings using char * A pointer to an array of bytes terminated by a null byte <string> This class provides a modern string interface to replace the C style stings string1 == string2 compares strings not pointers via overloading Supports modification using methods including insert, erase, and push_back Supports STL interfaces

  13. C++ Libraries I/O <iostream> cout << "thing to print"; Prints all the fundamental types Prints string variables Can be extended to print other types cin >> variable; Reads input from standard input Parses all fundamental types Spaces separate different inputs Will read words into string variables White space separates inputs and input is read with enter

  14. C++ STL The Standard Template Library C++ library parameterized by types similar to Java generics Containers Iterators Algorithms Functions

  15. C++ Libraries Variable Length Arrays <vector>

  16. C++ Libraries Dictionary or Associative Array <map> or <unorderd_map>

  17. Things start doing Get C++ (Xcode/Visual Studio/gcc) Make a helloworld.cpp program and build it.

Related


More Related Content