DEV Community

Cover image for Intro To C++

Posted on

Intro To C++

So as I wrapped up completing my resume and other job hunt related tasks I wonder to myself what would be next on my plate to learn. I always thought it would be cool to work with code and build stuff that would be fun for myself and others. As a kid when I think back I really just meant building games, now that I have an understanding of programming and how to build robust applications. I find myself leaning back into that "building games would be cool" state of thinking. So after a little research on what most big gaming companies use their choice of language when building these massive games, C++ looked like the go-to. Learning something new can be hard, weirdly though I didn't immediately think about how difficult it would be to learn a new language. Instead, I just jumped right into planning out time to pick off the language as a new skill while I search for a job.

Today in this blog I'll go over how C++ works(or how I see it currently). Then some of the fundamentals I picked up about C++.
Yeah so C++ is an object-oriented programming language. The language is known for being used for a lot of different things like a sort of general-purpose language. Let's cover some general standards for C++.

Variables - These are some of the variables in C++ these names represent the type and must be assigned specific values

int - stores integers (whole numbers), without decimals, such as 123 or -123
double - stores floating-point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
string - stores text, such as "Hello World". String values are surrounded by double quotes
bool - stores values with two states: true or false
In Use
int myNum = 5;               // Integer (whole number without decimals)
double myFloatNum = 5.99;    // Floating-point number (with decimals)
char myLetter = 'D';         // Character
string myText = "Hello";     // String (text)
bool myBoolean = true;       // Boolean (true or false)

Syntax - exactly what it sounds like the way the code is written

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!";
  return 0;

#include <iostream>

Its a Header file library that allows us to use input and output objects like cout(see out)

using namespace std

means that we can use names for objects and variables from the standard library.

  • their both kinda like how we import libraries in javascript
  • cout is a c++ object that is used with << to display variables We can allow user input by using cin(see out)
int x; 
cout << "Type a number: "; // Type a number and press enter
cin >> x; // Get user input from the keyboard
cout << "Your number is: " << x; // Display the input value

You can extend a display with more << like so

int myAge = 19;
cout << "I am " << myAge << " years old.";

These are pretty basic things to know since most languages include the majority of these standard operations. I still thought it would be cool to start here vs setting up C++ or using some specific comparison to another language. Honestly doing it this way simplifies learning it especially after another language in my opinion. As I continue to learn more about the language I hope to gain and share more knowledge from and back to the community.

Top comments (0)