Tech

What is C++? Explain in 500 Words

C++ a statically typed compiled programming language, famous for its widespread use and software infrastructure and infamous for its steep learning curve.

It was created in 1979 by Bjorn Strausstrup at T bell labs. He was inspired by the object-oriented nature of simula but needed a language with a high performance of C, and thus C with classes was born.

It’s designed as a superset of c which means virtually any c program is also a valid c++ program. Still, it also adds zero-overhead abstractions such as object-oriented patterns like polymorphism encapsulation and inheritance.

today it’s used in a wide variety of systems with constrained memory demands like the unreal engine for aaa video games programs like adobe after effects that were used to edit this video database, like MySQL and MongoDB embedded systems, like the display on your smart toaster and is used to implement much of our low-level infrastructures like language compilers and virtual machines

It’s so popular because it provides low-level memory and hardware control like c, but with high-level abstractions like classes and intelligent pointers, c++ makes it harder to shoot yourself in the foot, but when you do, it’ll blow your whole leg off.

Install a c plus compilers like GCC or clang, then create a file ending in CPP, including io stream from the standard library. Your code will start executing from the primary function to handle input and output.

To the print hello world, we use standard character output followed by the bitwise shift left operator and a string literal we can get rid of this std by adding a namespace to the top of the file.

If we want to create a string variable, we can do so by typing it as an array of characters; however, if we include string from the standard library.

We can use the string type instead of the actual game-changer because c++ supports object-oriented programming with classes. A class is just a blueprint for an object inside a class.

You can define attributes and methods that will be private by default or make them public by adding them under the public specifier.

It’s also possible to define methods outside the class definition using a double colon method that can also be specified multiple times with different parameters, which is known as overloading and is a form of polymorphism. In addition, we can define constructors and destructors to run code when an object is created or destroyed. Classes also support inheritance.

It allows developers to more efficiently share logic throughout a program to instantiate an object type the class name followed by the name of your object and optionally any parameters for the constructor when it comes to memory.

We could manage everything manually with pointers and references; however, tools like unique pointer can get the job done in a way that’s easier and safer by ensuring that. Only one object can be allocated to memory to run your code, open up the terminal and use a tool like a clang plus to compile.

Leave a Reply

Your email address will not be published.