C++ Programming

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

C++

- "C with classes" - developed in the 1970's by Bjarne Stroustrup - allows object oriented programming in C with C++ classes and objects - based on the C language / adding many powerful ft.s

variables

- A variable holds values for later use in other statements and expressions. - In C++, variables must be declared before they're used. - The variable may then be used to provide its value to statements and expressions later in your code.

statically typed

- C++ is a statically typed language (types are checked at compile time) - this process is referred to as type checking - C++ compiler checks whether the operations we write are supported by the types we use - compiler generates an error message and does not produce an executable file if we do things that the types don't support

comment

- Line oriented comment: // - Something in the source code not interpreted by the compiler - Multi-line comment: /* */

Expressions

- an expression is anything that returns value whether or not the value is used - may be part of a statement or may be the whole statement

identifiers

- can be composed of letters, digits, and the underscore character - identifiers must begin with either a letter or underscore - identifiers are case sensitive - identifiers we define in our own programs may not contain two consecutive underscores, nor can an identifier begin with an underscore followed immediately by an uppercase letter. - Identifiers defined outside a function may not begin with an underscore.

C++ Program

- collection of statements and expressions, usually organized into functions and classes.

#include

- directive for the preprocessor

definition

- it is a declaration - in addition to specifying name and type, it also allocates storage and may provide an initial value - any declaration that provides an explicit initializer is a definition

function

- larger unit of code that may contain many statements or expressions - designed to be re-used or called by another statement

main function

- main entry point of any C++ program - called by the os when u program first launches - one and no more than one

return 0;

- main function must return an integer value because main is an int function - 0 means success so it is standard to return 0 - sometimes you use a diff value top return an error

declaration

- makes a name known to the program - variables must be defined exactly once but can be declared many times

variables

- provides us with storage that our programs can manipulate - each variable in C++ has a type

list initialization

- the compiler will not let you use list initialization to initialize variables of built-in type if the initializer might lead to the loss of information / compiler rejects the initialization because it is likely to lose data

Identifiers

- tokens that provide readable names for variables, functions, labels, and defined types. - made up of letters and numbers within a set of constraints (1) the 26 letters of the ISO basic Latin alphabet - both lower case and upper case (2) the 10 Western Arabic numerals - 0 1 2 3 4 5 6 7 8 9 0 (3) ASCII underscore character ( _ ) - identifier may not be a numeral / may not conflict with reserved words

Statement

- unit of code terminated by a semicolon - Used: 1. to call functions 2. declare and initialize variables 3. operate on expressions

default initialization

- variables defined outside a function body are initialized to zero - variables defined inside a function body are undefined


Kaugnay na mga set ng pag-aaral

Chapter 7 - Membrane Structure and Function

View Set

Chapter 18 Origins of the Cold War

View Set

Bio 273 Exam 2 Self Check 6 part1 (Ch.6)

View Set