How to Start Learning C++: A U.S. News Guide News2america

C++ is a general purpose, object-oriented programming language that can be used to develop operating systems, games, graphical user interfaces, back end, and high-performance systems and applications.

(Getty Images)

Among the world’s most popular programming languages, C++ gives programmers lots of control over system resources and memory. It can be used to develop applications that run on multiple platforms such as servers, personal computers, cloud-based systems and mobile devices.

Learning C++ can help you if you’re interested in getting into computer games, software engineering for high-end computing projects, cryptocurrency mining programs and developing operating systems and other software for mobile devices.

A Short History of C++

C++ was created, designed and developed by Bjarne Stroustrup, a Danish computer scientist. Stroustrup wanted to make a flexible and dynamic language similar to C, but with additional capabilities.

Initially known as “C with classes,” it was renamed C++, meaning roughly “one higher than C,” in 1983.

The International Organization for Standardization’s C++ Joint Technical Committee upgraded C++ five times between 1998 and 2017. A new version, C++20, is scheduled to be released in the near future.

C vs. C++, What’s the Difference?

C++ is an evolution of C, and while they have some similarities, the two now are substantially different, says Jon Kalb, a software engineering instructor and chair of C++ Now, CppCon, and the C++ Track of the Silicon Valley Code Camp. While C is widely used, Kalb says it doesn’t support the abstractions, generic programming and object-oriented programming that C++ can.

“If you’re trying to do really ambitious projects that are going to need lots of code, then you’re going to want to be able to think in terms of very high-level abstractions. And that’s what C++ does: support those high-level abstractions,” Kalb says.

Abstraction layers refer to the amount of complexity with which a system is observed or programmed. Lower levels of abstraction have more detail, while high-level abstraction can encompass an entire system.

C is a procedural language; its code consists of instructions that directly tell the computer or its components to accomplish a task in logical steps. C++ can do that, but it also supports high-level features such as classes and object orientation, which allows programmers to create “objects” containing data and functions. The advantage of this approach is that software objects perform faster and are easier to execute than procedural commands, and object-oriented programming makes code easier to modify, maintain and debug.

Skill Level
Skill Level
Skill Level
Skill Level
Skill Level
Skill Level
Skill Level
Skill Level
Skill Level

Because C++ is popular, there are many resources available for beginners, including online tutorials, websites and books.

When deciding to learn C++ or any computer language, you should have some understanding about what you want to do with it professionally, says Kalb.

Most people working with C++ are software engineers, Kalb says. This is an important distinction, especially for those who recently graduated from college or have computer science backgrounds. While computer scientists work on more theoretical subjects, software engineers must deal with the details of solving a technical problem, something C++ is well-suited for.

“You write in C++ because you’re in a really demanding situation. Maybe you’re doing games where performance is absolutely critical. Or maybe you’re working on some kind of system software where, again, performance is critical, but so is the ability to be close to the metal, the bare metal of the machine, and C++ has that kind of ability,” Kalb says.

Before You Get Started with C++…

While anyone can learn to program in C++, having some prior programming experience can be helpful, says Josh Lospinoso, CEO of the cybersecurity company Shift5 and author of the book “C++ Crash Course.” Knowledge of basic computing terms such as statements, “for” loops, “while” loops and other structures common to C++ and languages such as JavaScript and Python is also useful.

“Just the basic programming principles would be really helpful when you’re starting out,” Lospinoso says. “For a basic C++ programmer, I really think understanding the syntax, and being able to go through a simple program and maybe print something out and be able to explain what each of the lines (of code) are doing, and then having an understanding of (data) types (are helpful).”

Resources and references to get started

But what if you don’t have those basic skills? Never fear; the internet is full of resources to help you off the ground. C++ Tutorial. This free online tutorial introduces C++ concepts in easy, step-by-step methods. The site covers basic topics such as syntax, output and comments before moving on to more complex terms like functions and object-oriented programming.

Codecademy Learn C++. This free online course offers an introduction to basic C++ programming concepts such as variables, conditionals and logic, and loops.

Step 1: Learn C++ Syntax and Do Some Tutorials

Syntax is a programming language’s grammar and the foundation for everything written in C++. This grammar also defines how C++ code is composed and understood.

#include <iostream> This is a header file library that imports features into a program. The command asks the program to copy content from a file called <iostream>, which stands for input and output stream. This format defines the standards for objects in C++ code.

Using namespace std refers to object and variable names from the standard library (std) and is often abbreviated with the keyword std and the operator ::.

int main ( ) specifies a main function. Functions are an important part of C++ programs because they define an action in the code. Commands contained in these brackets will be executed.

cout (pronounced see-out) is an object that defines outputs, or strings of words in the code. To write a new object, use cout on the second line. n will make the text execute on a different line.

Writing nn creates a blank space in a line of code.

return 0 instructs the program that nothing will return and strings of text will be the only output.

<< is an operator to name objects and ; (a semi colon) acts as a period for a line of code.

By putting these together, we can create a simple line of code to print the word “hello”:

# include <iostream>

using namespace std:

// main () this is where program execution begins.

Int main () {

cout << “Hello World” ; // prints Hello World

return 0;

Here are more resources to help beginning C++ programmers:

C++ Quick Reference. This guide lists all the major syntax expressions in C++, such as literals, declarations, statements and functions.

C++ All-In-One for Dummies Cheat Sheet. A supplement to the popular “For Dummies” book series, this reference offers tips such as the 10 most common C++ mistakes, standard C++ header files and additional syntax.

For Loop in C++ With Example. Loops are used in C++ to execute a block of statements repeatedly until specific conditions are met. This online tutorial provides a lesson in constructing “for” loops in C++ and links to guides for building “while” and “do-while” loops in C++.

Statements and Flow Control. This tutorial, part of a larger, free online C++ language guide, provides step-by-step lessons for creating a range of loops and statements in C++, what they do and how they’re used.

Step 2: Practice C++ Basics

After mastering syntax, a budding C++ programmer should get a grasp of bigger aspects of the language. These are:

Functions- A function is a group of statements that together perform a task. Every C++ program has at least one function.

Arrays- An array is a data structure that stores a fixed-sized sequential collection of the same kind of elements.

Strings- Strings are one-dimensional arrays of characters which are ended by a null character ‘’.

Pointers- Pointers are variables whose values are other variables’ addresses. Pointers help perform C++ tasks more easily, and some tasks can’t be performed without them.

References- A reference is an alias, another name for a variable that already exists. If a reference is initialized with a variable, that variable’s name and the reference name can be used interchangeably to refer to the variable.

Classes and Objects– Classes are a key feature of C++ used to specify the form of an object by combining data representation and methods for manipulating that data into one package. A class provides the material used to create objects.

Polymorphism- Polymorphism means having many forms. In C++, that refers to calling a number function to cause a different function to be executed, depending on the type of object invoking the function.

Constructors in C++. This tutorial helps programmers understand and build constructors, which initialize objects of a particular class.

C++ Primer (Fifth Edition). Updated for the C++11 standard, this comprehensive introduction to C++ highlights best practices and shows programmers how to use the core language and its standard library to write efficient code.

C++ Pocket Reference, First Edition. This quick reference book takes a practical approach to problem solving with C++ by describing real world problems and solutions, not just language features.

Step 3: Put Your Knowledge of C++ Into Practice

With some C++ programming skills learned, it’s time to put them to good use. One way to do this is by working on a project to see how various aspects of the language come together. There are many web-based resources for project ideas, such as programming simple games or building a banking app.

There are also many online communities for interests and applications of C++, so you can connect with hobbyists and part-time programmers or professionals.

Here are some online projects and resources to consider:

50+ C/C++ Projects with Source Code. This site provides a variety of simple programming projects in C and C++ like banking records and travel reservation systems, and simple games.

Stack Overflow Questions Tagged [C++]. Stack Overflow is an online forum catering to all types of programmers. Its C++ page is a place where programmers can pose questions to the community.

Reddit C++. This online C++ community covers a range of programming topics and interests for C++ programmers of all skill levels. It’s also where programmers can share tips and ideas.

C++ Soup!. This is a blog about new, upcoming and ongoing things in C++, including tips, tricks, reviews and commentary.

Step 4: Dive Into Advanced C++ Learning

Intermediate and advanced C++ programming builds on the basics and provides programmers with a range of tools. At the intermediate level, programmers need to understand how references and pointers work, says Lospinoso. Other core concepts underpinning the most powerful C++ functions are the object lifecycle and polymorphism. A firm understanding of these concepts and how to create and use library functions will put programmers on the road to learning advanced techniques.

At the most advanced levels, good C++ programmers can step away from object-oriented programming to make use of more generic types of programming, says Kalb. There’s nothing wrong with object-oriented programming – in fact, it’s still being used by millions of programmers – but cutting-edge programmers take their skills to the next level, he adds.

“The programmers that get it are using generic programming and are doing things with compile time to increase their runtime controls. They’re writing code that’s generic so that it can be easily adapted (across many platforms),” Kalb says.

C++ Crash Course. Intended for intermediate to advanced programmers, this book provides tips for working with C++17, the most modern version of the ISO standard. It also covers the core of the language, from types and functions to the C++ Standard Library and Boost Libraries.

C++ for Fun and Profit. This video of a talk at West Point by Lospinoso, who graduated from the military academy, is about how learning C++ helped him professionally.

C++ and Java are often presented as competing programming languages, but they are used for different types of programming, Lospinoso says. Java uses virtual machines – software that acts like hardware – to perform a variety of functions. It’s often used for applications that can run on many platforms including Windows, Linux, Mac, Android and Apple iOS.

C++ is also cross-platform, but it requires a separate program to be compiled for it to work on each system, Lospinoso says. Where C++ shines is its ability to be written in memory-efficient applications that run closer to the machine’s working elements.

In the end, it’s a choice between general compatibility, which makes Java popular, and focused efficiency when memory and performance are important. That is where C++ shines.

  • Learn the syntax.
  • Master basics such as functions, arrays and strings.
  • Take advantage of resources like online tutorials, books and lectures.
  • Be persistent. Coding, like many skills, takes time to learn. Don’t be afraid to make mistakes.

Source link


Learn More →

Leave a Reply

Your email address will not be published. Required fields are marked *