Wednesday, August 4, 2021
Memory Management New and Delete

Memory Management New and Delete in C++

Memory Management : We’ve seen many examples where arrays are used to set aside memory. The statement int arr1; reserves memory for 100 integers. Arrays are a useful approach to data storage,...
Passing Pointers to Functions in C++

Passing Pointers to Functions in C++

Before we noted that there are three ways to pass arguments to a function: by value, by reference, and by pointer. If the passing pointers to functions in C++ is intended...
pointers and arrays

Pointers and Arrays in C++

There is a close association between pointers and arrays. “Arrays and Strings,” how array elements are accessed. The following program, ARRNOTE, provides a review. // arrnote.cpp // array accessed with array notation #include <iostream> using...
Overloading Binary Operators

Overloading Binary Operators in C++

Overloading binary operators can be overloaded just as easily as unary operators. We’ll look at examples that overload arithmetic operators, comparison operators, and arithmetic assignment operators. Arithmetic Operators In the ENGLCON program in...
Overloading Unary Operators

Overloading Unary Operators in C++

Let’s start off by overloading a unary operators. unary operators act on only one operand. (An operand is simply a variable acted on by an operator.) Examples of unary operators are...
C++ Strings

C++ Strings – theteche.com

We noted at the beginning of this chapter that two kinds of strings are commonly used in C++: C-strings and strings that are objects of the string class. In this section...
Arrays of Objects

Arrays of Objects – Arrays of English Distances

We’ve seen how an object can contain an array. We can also reverse that situation and create an arrays of objects. We’ll look at two situations: an array of English distances...

Const Member Function in C++ Example Program

A const member function guarantees that it will never modify any of its class’s member data. The CONSTFU program shows how this works. //constfu.cpp //demonstrates const member functions / class aClass { private: int alpha; public: void nonFunc() //non-const member...
Static Data Member

Static Data Member in C++ Example

Having said that each object contains its own separate data, we must now amend that slightly. If a data item in a class is declared as static, only one such item...
The Default Copy Constructor in C++

The Default Copy Constructor in C++

We’ve seen two ways to initialize objects. A no-argument constructor can initialize data members to constant values, and a multi argument constructor can initialize data members to values passed as arguments....