top of page

C++ Basics : Points to Remember

Updated: Aug 29, 2023


C++ Basics
C++ Basics

1. The speed of a computer is usually expressed in cycles per second. Typical machines operate at 100 to 200 megahertz or 100 million cycles per second.

2. Computers use the binary number system. A binary digit is called a bit.

3. The basic unit of storage in a computer is a byte or 8 bits.

4. Negative numbers are usually stored in two’s complement representation . In this representation , an n-bit number can represent the values in the range –2n-1 through 2n-1 –1.

5. The central processing unit is the brain of a computer .It is where arithmetic and logical functions are performed.

6. The size of a computer’s random access memory or RAM is measured in megabytes (MB).

7. The capacity of hard disks found on current desktop machines ranges from 0.5 to 4.3 gigabytes(GB).

8. The programming language is a language that gives commands or instruction to computer.

9. A compiler translates a programming language to machine language . A machine language consists of primitive operations that a computer can perform directly.

10. Application software is software that solves a particular problem or provides a particular service.

11. System software is software that supports the development and execution of other programs.

12. An operating system is system software that supports the development and execution of other programs.

13. An operating system is system software that controls and manages the computing resources such as the memory,the input and output devices, and the CPU.

14. Information is stored on a disk in a hierarchy of files so it can be found and retrieved quickly.

15. An algorithm is a detailed , step by step description of how to perform some task.

16. The goal of SW Engineer is to produce software that is reliable , understandable, cost effective , adaptable and reusable.

17. Abstraction is the process of isolating the essential ,inherent aspects of an object while ignoring nonessential or irrevelent details.

18. Encapsulation or information hiding is the process of separating the external aspects of an object , which can be viewed or accessed by other objects from the internal implementation details , which should be hidden from other objects.

19. Modularity is the process of dividing an object into smaller pieces so each smaller object or module can be dealt with individually.

20. An inheritance hierarchy is a way of organizing a set of abstractions from most general to least general.

21. Object –oriented design and programming is a paradigm of programming in which a software system is modeled as a set of objects that interact with each other.

22. In C++ an abstraction is formed by creating a class . A class encapsulates the properties and behaviors of an object.

23. The data members of a class are the properties or attributes of a class.

24. The member functions of a class are the behaviors of a class.

25. A base class is one from which other, more specialized classes can be derived.

26. A derived class inherits properties from a base class.

27. Polymorphism is the capability of something to assume different forms . In an object-oriented language , polymorphism is provided by allowing a message or member function to mean different things depending on the type of object that receives the message.

28. Instantiation is the process of creating a concrete object from the class abstraction.

29. The statement #include <iostream.h> is a preprocessor directive that includes the necessary definitions so that a program can do input and output using the iostream library.

30. The statement using namespace std; makes the objects defined in the namespace std available for use.The iostream objects (cin and cout) are defined in the namespace.

31. The c++ operator << is called insert operator. It is used to insert text into an output stream.

32. The output stream cout normally corresponds to the display.

33. The c++ operator >> is called the extraction operator. It is used to extract characters from an input stream.

34. The input stream cin normally corresponds to the keyboard.

35. The manipulator endl inserts a new line in the output stream. In addition, it forces all the output that has been sent to the stream to be written to the corresponding device.

36. Standard C++ programs begin executing in function main(). Function main() returns an integer value that indicates whether the programs executed successfully or not . The value 0 indicates successful execution of the program.

37. A value is returned from a function using the return statement. The statement return 0 returns the value 0.

38. A C++ style comment begins with // and continues to the end of the line.

39. The assignment operator = assigns or gives a new value to an object.

40. The C++ object types short, int and long hold integer values .On PC the short is stored in 8 bits ,an int in 16 bits and a long in 32 bits.

41. The C++ object type char holds a character. For most machines characters are encoded using the ASCII character set.

42. The C++ object types, float, double and long double hold real values. On the PC, a long is stored in 32 bits, and a double is stored in 64 bits. On most PC’s a long double is the same size as a double, but on other machines it can be larger.

43. A C++ string constant is a sequence of characters enclosed in double quotes. Special characters such as the newline, tab and bell can be include in a string constant using special escape characters.

44. A C++ integer constant can be written in one of the three bases: octal, decimal, or hexadecimal. An octal integer constant begins with a zero digit. Thus, the constant 040 is octal and represents the decimal value 32.Decimal constants begin with a digit other than zero, and hexadecimal constants begin with the prefix ox or OX. The constant 0x40 represents the decimal value 64.

45. C++ provides several ways to write a floating –point constant . The simplest way is to use standard decimal notation : 3.1416,2.53,0.3512. Floating –point constant 2.3E5 represents the value 2.3X105 or 230.000.

46. A C++ name consists of a sequence of letters (uppercase and lowercase),digits and underscores. A valid name cannot begin with a digit character.

47. C++ names are case sensitive.

48. It is very important to pick meaningful and descriptive names for the objects in a program. Descriptive names help other programmers understand what your program is doing.

49. An object must be defined before it can be used ,Smart programmers give an object an initial value when it is defined.

50. Integer division always produces a truncated result. The expression 5/2 produces the result 2 and not 2.5.

51. The usual unary conversions specify that operands of type char or short are converted to type int before proceeding with the operation.

52. For an arithmetic operation involving two integral operands, the usual binary conversions specify that when the operands have different types, the one that is type int is converted to long and a long operation is performed to produce a long result.

53. A mixed mode arithmetic expression involves integral and floating–point operands. The integral operand is converted to the type of the floating-point operand, and the appropriate floating-point operation is performed.

54. The precedence rules of C++ define the order in which operators are applied to operands. For the arithmetic operators , the precedence from highest to lowest is unary plus and minus ;multiplication, division, and subtraction.

55. Always initialize an object when it is declared .

56. When a floating-point value is stored in an integer object ,the floating-point value is converted to an integer value by truncating its value.

57. The assignment operator is right associative and has lower precedence then the arithmetic operators.

58. The C++ keyword const. is used to define objects that should not be modified. This technique is useful for defining objects that hold values that represent physical constants, values that are conversion factors, and other values that should not changed during the execution of the program.

59. The iostream object cin is an input stream. it is normally associated with input from the keyboard.

60. Input is extracted from an input stream using the extraction operator>>. The extraction operator can extract integer, floating point and character values from an input stream.

61. When writing a program that accepts input from a human user, the program must issue prompts that clearly indicate what input is requested and the form of the input.

62. The most important characteristic of a program is correctness and comprehensibility, When faced with the choice between clarity and a possible gain in performance, the correct choice is almost always clarity.

63. The C++ standard library includes many useful classes. Part of mastering C++ is learning what facilities exist and when to use them.

64. The string class is designed for string and manipulating sequences of characters.

65. The directive #include<string>

66. Must be included to access the facilities provided by the string library

67. A string can be initialized with another string or a string constant. A string cannot be initialized with a character.

68. The sequence of characters that constitute a string object does not include a terminating ‘\0’ character.

69. Concatenation is the process of creating a new string by “gluing“ together two strings. The + operator is the concatenation operator.

70. When applied to two strings, the += operator performs an append opeartion.

71. The C++ compound assignment operators +=,-=,*=,/=,and %= perform an arithmetic operation on an object and store the resulting value back into the object.

72. C++ has special operators ++ and – for incrementing and decrementing integral and floating point objects. There are pre and post versions of these operators. With the post increment and post decrement operators,the value of the expression is the value of the object before it is modified.

73. The type bool is used in C++ for representing logical values.

74. A logical expression evaluates to true if the value of the expression is either a nonzero integer value or the bool value true.

75. A logical expression evaluates to false if the value of the expression is integer 0 or the bool value false.

76. Logical expression can contain the logical operators && ,|| and !. These operators correspond respectively to and , or and not.

77. A truth table is the traditional representation for a logical operation. A table will contain an entry for each possible logical operand combination.

78. The relational operators also produce logical values.The relational operators fall into two categories: equality and ordering.

79. The equality operators ==and != and the ordering operators<,<=,>=,and >= are defined for all fundamental and pointer types and the string class.

80. Because of its limitations in accuracy, floating point values are typically not tested for equality. Instead tests are made to determine whether floating point values are approx. equal.

81. A logical expression that is being evaluated is subject to the short-circuit rule . This rule states that once the overall value of an expression is known ,evaluation ceases.(as in the case of && and || operators).

82. The if statement has two forms .In both forms ,a logical expression is evaluated, and if that expression is true ,an action is executed. In one of the forms, an action is also specified when the evaluated expression is false.

83. The expression used to determine the course of action for a conditional or iterative construct is known as a test expression.

84. The switch statement takes actions based on the value of an integer expression. The programmer specifies the case values of interest for that expression, and for each case value the desired action is specified. The switch statement allows for an optional default case that handles non specified values.

85. Types defined by a programmer are known as programmer defined or derived types.

86. The enum statement is a method for organizing a collection of integral constants into a type.

87. A loop is a group of statements whose actions are repeated using an iterative construct.

88. The while statement permits actions to be repeated while a given logical expression evaluates to true.If the logical expression is initially false, then the action of the construct is never executed ;otherwise ,the action is repeatedly executed until the test expression evaluates to false.

89. Because a while test expression can be initially false ,it is possible for the body of a while loop not to be executed.

90. The do statement is similar in nature to the while statement; however, its action is always executed at least once. It has this property because its test expression is not evaluated until after its body is executed.

91. The for statement is a specialization of the while construct that has a test expression and both a one-time loop initialization action and an action that is to be performed once for each execution of the loop body. All parts of a for statement are optional. In particular ,if the test expression is omitted, then the value true is instead.

92. An object defined in the ForInit section of a for loop can be used only in that loop.

93. A break statement causes the innermost switch ,while,for ,or do control structure that contains the statement to be exited.

94. As in other parts of programming ,loops should be carefully constructed. Actions taken before and during the loop should ensure that the test expression for the loop always makes sense. These actions should also ensure that the loop eventually terminates.

95. An invariant is a rule that should be always true. In developing a loop,the designer should be aware of the invariants that the loop can affect.

96. A typedef statement creates a new name for an existing type. Both the new and old names can be used in subsequent definitions.

97. Software reuse is important if programs are to be developed quickly and efficiently. One of the major sources of software is the standard libraries.

98. C++ provides a significant number of libraries for a variety of application areas. Some of the more important stream libraries are the iostream,iomanip and fstream libraries. These libraries provide mechanisms for inserting and extracting information in a controlled manner.

99. A header file is a collection of function interfaces, constant and variable object definitions and class descriptions. The header file is incorporated into the definitions and class descriptions. The header file is incorporated into the program through an include directive.

100. Information to a function is passed via parameters. The function’s computation is normally brought back as the return value. The type of value brought back by a function is the return type .A function that does not return a value has the type void.

101. The parameters in the invocation are called the actual parameters. The actual parameters are represented in the invoked function by its formal parameters.

102. When a function is invoked, flow of control is transferred from the invoking function to the invoked function. When the invoked function completes, control is transferred back to the invoking function. If the invoked function returns a value, then that value is essentially substituted for the invocation.

103. Every function invocation creates an activation record. The values of the formal parameters and other objects defined in the function are kept in the activation record.

104. Before a function in invoked, it must be prototyped or defined. A prototype is a description of the function’s interface. A function definition contains both a description of the function’s interface and its statement body. A description of the interface specifies the return type, function name, and the form of the parameter list.

105. One way of passing actual parameters is the pass – by value parameter passing style. When an actual parameter is passed in this style, the formal parameter is called a value parameter because it is initialized to the value of the actual parameter. Subsequent changes to the formal parameter do not affect the actual parameter.

106. All the standard libraries have header files that prototype the functions defined in those libraries. Depending on the library, the header file may also contain object, class, and function definition.

107. When including a standard library in a program, it is also standard practice to have the statement

108. Using namespace std;

109. If this statement is not included then each reference to the library must be prepended with std::.

110. The preprocessor is responsible for processing three kinds of commands in a program file. The file inclusion directives specify files that are to be part of the translation unit that is to be compiled. Macro definition and invocation provide textual substitution. Conditional compilation directives allow a programmer to restrict the lines of the code that are compiled.

111. A hierarchy of classes exists for representing input and output streams. The root of this hierarchy is the class ios_base.

112. Two important stream classes are istream and ostream. Class istream is a root of the subhierarchy for input streams; class ostream is a root of the subhierarchy for output streams.

113. Classes ifstream and ofstream are for defining streams that manipulate files. These streams process extractions and insertions, respectively.

114. Classes iostream and fstream define strteams capable of both extractions and insertions.

115. The iostream library defines two streams for error messages. Stream cerr is for unbuffered error messages; stream clog is for buffered error messages.

116. The iostream library also defines manipulators for specifying how to perform stream insertions and extractions.

117. A manipulator that controls successive I/O operations is persistent.

118. The iostream manipulator dec, oct, and hex control the base in which numbers are displayed.

119. The iostream manipulator flush causes the contents of the output buffer to be displayed immediately.

120. The iomanip library also provides stream manipulators. Two of its important manipulators are setw() and setprecision(), which allow the width and precision of an insertion to be specified.

121. The iostream manipulators fixed and scientific control whether a numeric value is displayed in decimal or scientific notation.

122. The iostream manipulators skipws and noskipws control whether whitespace is extractable using the insertion operator.

123. The math library provides access to trigonometric, exponential, and logarithmic funtions. The math library is a C-based library. To include the library, we use either header file cmath or header file math.h.

124. The ctype library provides functions for testing whether character objects have specific properties. The ctype library is a C-based library. To include the library, we use wither header file cctype or header file ctype.h.

125. The assert library defines an assert macro that enables an integral expression to be evaluated. If the expression is false, the program is terminated. If the expression is true, program execution continues in a normal manner. The assert library is a C-based library. To include the library, we use either header file cassert or header file assert.h.

126. The stdlib library is a collection of miscellaneous utility functions. The assert library is a C-based library. To include the library, we use either header file cstdlib or header file stdlib.h.

127. The stdlib library function exit(), when invoked, immediately terminates the program. The parameter to exit() is used as the program return value.

128. A function is a mechanism that permits modular programming and software reuse.

129. The simplest functions take parameters in a manner similar to mathematical functions and then compute and return a value to be used in an expression.

130. A statement block is a list of statements within curly braces.

131. A nested block is a statement block occurring within another statement block.

132. To define a function, a programmer must completely specify its interface and actions. The actions occur within the function body. The function body is a statement block.

133. A return statement supplies a value from the invoked function to the invoking function.

134. A local object is an object defined within a statement block.

135. A global object is an object defined outside of any function interface or function body.

136. To complete their tasks, functions can use local and global objects and even other functions.

137. To invoke a function, a programmer supplies actual parameters of the correct types. If the actual parameters do not match the types of the formal parameters, the compiler will attempt to perform conversions to put the actual parameters in the correct form.

138. An activation record is memory that the function uses to store its parameters and local objects.

139. For each function invocation, a new activation record is created.

140. Typical programming efforts span multiple files. The files are individually complied and linked together to produce and executable version of the program.

141. A header file is often used to prototype functions that are defined in implementation files. Through the use of header files, functions defined in one implementation file can be invoked within another implementation file.

142. Names can be reused as long as the declaration associated with the names occur in different blocks.

143. The unary scope resolution operator:: can be used to reference a global object whose name has been reused in the local scope.

144. Global fundamental objects are initialized to zero by default.

145. A reference to a global object in an implementation file requires that the global object be either defined or declared using an extern statement within the translation unit of that implementation file.

146. A global object can be defined only once in the global scope of the program.

147. In top-down design, you determine the basic tasks that must be performed and how these tasks must interface and interact. If necessary, the basic tasks are decomposed until all actions are will understood and can be easily implemented.

148. The sstream library provides in-memory streams that can act like string buffers.

149. Through a series of insertions, an ostring stream object can create a string representation of the values of other objects.

150. Recursion in when a function calls itself. A recursive function must have two parts. It has a termination part that ends the recursion and a recursive call with simpler parameters.


7 views0 comments

Recent Posts

See All

C++ Basics : Points to Remember

Points to remember………….! Go through it very thoroughly ………..! 1. The speed of a computer is usually expressed in cycles per second. Typical machines operate at 100 to 200 megahertz or 100 million cycl

bottom of page