C++ Tutorials

71. Dot (.) vs Arrow (->) to access data members in C++

By: Ivan Lim : 2007-09-14

Description: Normally you can access data members and functions by using the dot (.) operator for Cat objects created locally. To access the Cat object on the free store, you must dereference the pointer and call the dot operator on the object pointed to by the pointer. Therefore, to access the GetAge member function, you would write


72. this Pointer in C++

By: Jagan : 2007-09-14

Description: Every class member function has a hidden parameter: the this pointer. this points to the individual object. Therefore, in each call to GetAge() or SetAge(), the this pointer for the object is included as a hidden parameter.


73. Stray or Dangling Pointers in C++

By: Kamini : 2007-09-14

Description: One source of bugs that are nasty and difficult to find is stray pointers. A stray pointer is created when you call delete on a pointer--thereby freeing the memory that it points to--and later try to use that pointer again without reassigning it.


74. const Pointers in C++

By: Lakshmi : 2007-09-14

Description: You can use the keyword const for pointers before the type, after the type, or in both places. For example, all of the following are legal declarations:


75. What Is a Reference in C++?

By: Manoj Kumar : 2007-09-14

Description: A reference is an alias; when you create a reference, you initialize it with the name of another object, the target. From that moment on, the reference acts as an alternative name for the target, and anything you do to the reference is really done to the target.


76. Tutorial on Inline Implementation in C++

By: Jagan : 2007-09-09

Description: Just as you can ask the compiler to make a regular function inline, you can make class methods inline. The keyword inline appears before the return value. The inline implementation of the GetWeight() function, for example, looks like this:


77. Using switch Statements in C++

By: Emiley J : 2007-09-09

Description: if and if/else statements can become quite confusing when nested too deeply, and C++ offers an alternative. Unlike if, which evaluates one value, switch statements allow you to branch on any of a number of different values. The general form of the switch statement is:


78. Nested Loops in C++

By: Daniel Malcolm : 2007-09-09

Description: Loops may be nested, with one loop sitting in the body of another. The inner loop will be executed in full for every execution of the outer loop. This c++ program illustrates writing marks into a matrix using nested for loops.


79. Multiple statements in for loops in C++

By: Charles : 2007-09-09

Description: for statements are powerful and flexible. The three independent statements (initialization, test, and action) lend themselves to a number of variations.


80. for Loops in C++

By: Baski : 2007-09-09

Description: When programming while loops, you'll often find yourself setting up a starting condition, testing to see if the condition is true, and incrementing or otherwise changing a variable each time through the loop. The following program demonstrates this.