comprog mod 2

Cards (37)

  • MODULE 2: BRIEF HISTORY OF C++, COMPONENTS
  • C++
    One of the world's most popular programming languages, found in operating systems, GUIs, and embedded systems. It is an object-oriented programming language that gives a clear structure to programs and allows code reuse, lowering development costs. C++ is portable and can be used to develop applications that can be adapted to multiple platforms.
  • Object-oriented programming
    Gives a clear structure to programs and allows code to be reused, lowering development costs
  • History of C++
    1. Bjarne Stroustrup developed C++ at AT&T Bell Labs
    2. C++ was first introduced in 1979 as "C with Classes"
    3. C++ was renamed in 1983
    4. First commercial edition released in 1985
    5. C++ has evolved over the years with new versions released (C++98, C++03, C++11, C++14, C++17)
  • C++
    A collection of objects that communicate via invoking each other's methods
  • Object
    • Has states and behaviors
  • Class
    A template/blueprint that describes the behaviors/states that objects of its type support
  • Method
    A behavior, where the logic is written, data is manipulated, and actions are executed
  • Instance variable
    Each object has its unique set of instance variables, which create the object's state
  • C++ identifier
    A name used to identify a variable, function, class, module, or any other user-defined item. It starts with a letter or underscore and can contain letters, underscores, and digits.
  • Whitespace
    Blanks, tabs, newline characters, and comments that separate one part of a statement from another and enable the compiler to identify where one element ends and the next begins
  • Enumerated type
    Declares a new type-name along with a sequence of values containing identifiers which have values starting from 0 and incrementing by 1 every time
  • What are the modifiers in C++
    • long
    • short
    • signed
    • unsigned
  • Variables in C++

    Used to store values that change in the program. Each variable must be given a data type, which determines the memory assigned to the variable.
  • Basic types of variables in C++
    • bool
    • char
    • int
    • float
    • double
  • int
    Minimum size is short
  • Size hierarchy
    • short int
    • int
    • long int
  • Size hierarchy for floating point numbers

    • float
    • double
    • long double
  • long float is not a legal type and there are no short floating point numbers
  • Signed types
    Includes both positive and negative numbers and is the default type
  • Unsigned
    Numbers are always without any sign, that is always positive
  • Variables in C++

    Used where we need storage for any value, which will change in program
  • Variable declaration
    Must be given a datatype, on which the memory assigned to the variable depends
  • Basic types of Variables
    • bool
    • char
    • int
    • float
    • double
  • Declaration and Initialization
    1. Variable must be declared before they are used
    2. Initialization means assigning value to an already declared variable
  • If a variable is declared and not initialized by default it will hold a garbage value
  • If a variable is once declared and if try to declare it again, we will get a compile time error
  • Variable Scope in C++
    • Local variables (inside a function or block)
    • Formal parameters (in function definition)
    • Global variables (outside all functions)
  • Local Variables
    • int a, b, c
    • a = 10
    • b = 20
    • c = a + b
  • Global Variables
    • int g
    • g = a + b
  • A program can have same name for local and global variables but value of local variable inside a function will take preference
  • Types of Operators in C++
    • Arithmetic Operators
    • Relational Operators
    • Logical Operators
    • Bitwise Operators
    • Assignment Operators
    • Misc Operators
  • Arithmetic Operators
    • +
    • -
    • *
    • /
    • %
    • ++
    • --
  • Relational Operators
    • ==
    • !=

    • >|>=
    • <=
  • Logical Operators
    • ||
    • &&
  • Bitwise and Bit Shift Operators
    • ~
    • <<
    • >>
    • >>>
    • &
    • ^
    • |
  • Assignment Operators
    • +=
    • -=
    • *=
    • /=
    • %=
    • <<=
    • >>=
    • &=