Learning C++, Basic Data Types and Operators (C++)

The Coronavirus lockdown here in the UK is starting to ease, but it still means a lot of time at home. I’m trying to use that time to be more productive and learn more, which has lead me to C++.

C++

C++ has a long history (going back to 1985) and is a high level programming language. It was created by Bjarne Stroustrup and is an extension of the programming language C. C++ looks to have a new version every three years. Wikipedia’s C++ page has more details.

Why C++

Depending on the source, C++ is (at time of writing) one of the top five programming languages to know. I have already got some experience with Python, Java and C, so I thought it was time to learn a bit about C++.

geektechstuff_cpp_crash_course_cover
C++ Crash Course (Josh Lospinoso) from No Starch Press

For this learning I have started with Microsoft’s Introduction To C++ via EdX and No Starch Press’ C++ Crash Course (written by Joshua Lospinoso). I’m hoping to use my blog to make notes about C++ that I may need in future, starting with the basic data types and operators.

Basic Data Types

Examples Of C++ Data Types
Examples Of C++ Data Types

This is a small sample of some of the data types available in C++ but should be enough for me starting out. char is a single character, and multiple characters are a string.

Operators

C++ comes with several operators already defined, these include the basic mathematical operators such as:

+        addition         e.g.      x+y
-        subtraction      e.g.      x-y
*        multiplication   e.g.      x*y
/        division         e.g.      x/y
%        modulo           e.g.      x%y

The short hand mathematical operators:

+=       e.g. x+=y which would be the same as x=x+y
-=       e.g. x-=y which would be the same as x=x-y
*=       e.g. x*=y which would be the same as x=x*y
++       increase by 1
--       decrease by 1

The comparison operators:

==       equal to
!=       not equal to
>        greater than
>=       greater than or equal to
<        less than
<=       less than or equal to

The logic operators:

&&       logical AND
||       logical OR
!        logical NOT

 

2 responses to “Learning C++, Basic Data Types and Operators (C++)”

  1. Learning C++: Arrays, Enumerations, Structs and Unions (C++) – Geek Tech Stuff Avatar

    […] though some excellent (for me) news, on my C++ learning path (started in my last blog entry) I have completed DEV210x: Introduction to C++ via […]

    Like

  2. Learning C++: Preprocessor, Compiler, Linker and “Hello, World!” – Geek Tech Stuff Avatar

    […] blog posts on C++ so far have looked at the basic data types and arrays, structs, enums and unions. With this blog post I am going to look at the 3 steps used […]

    Like

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect