A Simple C++ Program

Similar Posts

  • Class Templates

    Not only can you use templates for a primitive data type within functions, but also within classes. Consider the following example: The methods are similar to a non-template class, however, each method is a template itself, so you have to adjust a few things. For example, you have to specify template<typename T> before each method….

  • Default Arguments

    C++ has added the ability to have default arguments be defined when you declare your functions. To define a default value, you must specify the parameter name, and then assign it a value. If someone calls this function without passing an argument to the function, the computer will use 20 as the parameter. If they…

  • Break and Continue

    We’ve seen the break in a switch statement. It stops running the blocks of code, and simple exits out of the switch. In the same manner, if you use a break in a loop, it exits us from the loop prematurely (not by the loop condition). The continue keyword moves us to the end of…

  • Thinking in Objects

    Traditional procedural programming focuses on actions – functions. Object oriented programming focuses on data (objects) and the operations on objects. You want to look at items that you will be coding, and think, what makes this information up? and, What things can it do, and/or be done to it? Objects in the physical realm are…