Stray or Dangling Pointers in C++
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 t
Read tutorialTHE TUTORIAL LIBRARY
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 t
Read tutorialEvery 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 th
Read tutorialNormally 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 t
Read tutorialThe program below demonstrates allocating a variable on the heap, using that variable, and deleting it.
Read tutorialLocal variables are on the stack, along with function parameters. Code is in code space, of course, and global variables are in global name space. The registers are used for intern
Read tutorialOnce a pointer is assigned the address of a variable, you can use that pointer to access the data in that variable. Program below demonstrates how the address of a local variable i
Read tutorialThe indirection operator (*) is also called the dereference operator. When a pointer is dereferenced, the value at the address stored by the pointer is retrieved.
Read tutorialEvery variable has an address. Even without knowing the specific address of a given variable, you can store that address in a pointer.
Read tutorialPointers present two special challenges when learning C++: They can be somewhat confusing, and it isn't immediately obvious why they are needed. This article introduces how pointer
Read tutorialif 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 bra
Read tutorialLoops 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 writi
Read tutorialfor statements are powerful and flexible. The three independent statements (initialization, test, and action) lend themselves to a number of variations.
Read tutorialOne example today. A better developer tomorrow.