Defining New Datatypes

Similar Posts

  • 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…

  • 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…

  • C-Strings in C++

    A C String is actually an array of characters. While C strings are a thing, generally speaking it is best to use the C++ string object. However, if you run into an older application, or someone who wants to do things old style, it is good to know how to use a C-String. Additionally, any…

  • C++ Math

    C++ gives you a lot of ways to do math, built into the language directly. Unfortunately, it can get complex – so we’re going to focus on the simple stuff. The order of operation in C++ is the same as in algebra, so that is easy to remember. + is addition – is subtraction *…

  • Data Field Encapsulation

    Previously we looked at a class Circle, which had a property radius that was publicly available. That means that any other class, or your main program could change that value. This is a problem for two reasons: First, that data could be tampered with. Another function, class, etc could directly access the variable and change…