cover photo

RESOURCE Β· 14/4/2023

GUIDE TO C++

BY ANJALI RAO

Anjali Rao SG
Anjali Rao SG
OP
GUIDE TO C++

🎊A Beginner's Guide to C++🎊\n\n##### Welcome to the world of C++ programming! If you're looking to dive into the exciting and powerful world of computer programming, then C++ is an excellent place to start. From building your own applications to creating games and other interactive programs, C++ has the flexibility and versatility to handle just about any programming task you can imagine.\n\n
\n\n##### In the course of this tutorial you will learn the basic jargons of C++ starting from understanding the history of this language to the basic data structures and data types.\n\n
\n\n### Happy Journey and may the force be with you!πŸ‘οΈ\n\n
\n\n### Contents \n\n##### 1) History ft.C++\n##### 2) A time to welcome C++ a.k.a downloading C++\n##### 3) The cliched first - executing HelloWorld.cpp\n\n\n

\n\n#### 1) History ft.C++πŸ“–\n
\n\nalt text or description \n\n##### C++ is a high-level, object-oriented programming language that was created by Bjarne Stroustrup in the early 1980s. Stroustrup initially designed C++ as an extension of the C programming language, adding features such as classes, virtual functions, and operator overloading to create a more flexible and powerful language. The first version of C++ was released in 1985, and it quickly gained popularity among developers due to its ease of use, performance, and flexibility.\n
\n\n##### Throughout the 1990s and 2000s, C++ continued to evolve and become more widely used, particularly in industries such as finance, gaming, and embedded systems. In 2011, the ISO C++ standard was updated with a new version of the language, known as C++11, which added new features such as lambda expressions, initializer lists, and threading support.\n
\n\n##### Today, C++ remains one of the most popular programming languages in the world, used in a wide range of applications from operating systems and databases to video games and scientific simulations. Its long history and continued evolution have made it a powerful and versatile tool for developers, and its popularity shows no signs of slowing down anytime soon.\n
\n\n##### C++ is an object oriented program. Object-Oriented Programming or OOPs refers to languages that use objects in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.\n
\n \n### OOPS CONCEPTS:\n
\n\n#### 1. CLASS\n##### It is a user defined data type which consists of data members and member functions. For example- Consider the Class of Cars. There may be many cars with different names and brands but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range, etc. So here, Car is the class, and wheels, speed limits, mileage are their properties.\n
\n\n#### 2. OBJECTS\n##### An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. An object has an identity, state, and behavior. Each object contains data and code to manipulate the data. For example- β€œDog” is a real-life Object, which has some characteristics like color, Breed, Bark, Sleep, and Eats.\n
\n\n#### 3. DATA ABSTRACTION\n##### Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation. For example- The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car, but he does not know about how on pressing the accelerator the speed is increasing, he does not know about the inner mechanism of the car or the implementation of the accelerator, brakes, etc in the car.\n
\n\n#### 4. ENCAPSULATIOn\n##### Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Example in real life, consider a company with different departments here data of the sales section and the employees that can manipulate them are wrapped under a single name β€œsales section”.\n
\n\n#### 5. INHERITANCE\n##### The capability of a class to derive properties and characteristics from another class is called Inheritance. When we write a class, we inherit properties from other classes. This can be seen in real life as well. Children inherit characteristics from their parents.\n
\n\n#### 6.POLYMORPHISM\n##### The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. For example, A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations.\n
\n\n#### 7. DYNAMIC BUILDING\n##### Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time. \n
\n\n#### 8. MESSAGE PASSING\n##### It is a form of communication used in object-oriented programming as well as parallel programming. Objects communicate with one another by sending and receiving information to each other. Message passing involves specifying the name of the object, the name of the function, and the information to be sent.\n\n### NOTE: \n#### C++ is an Object Oriented Language\n#### In C++ every line of the code must end with a semi-colon ( ; )\n\n
\n
\n\n### 2) A time to welcome C++ a.k.a downloading C++πŸ”½\n
\n\n##### Depending on the operating system that you are currently using, you can follow any one of the tutorial given below:\n
\n\n##### a) For MAC OS use - https://www.youtube.com/watch?v=YuutFT6Yhic\n
\n\n##### b) For Windows OS use - https://www.youtube.com/watch?v=NTkwZsUasXU\n
\n\n##### c) For Linux OS use - https://www.youtube.com/watch?v=QKUhMOd-KOM\n
\n\n##### d) If you want to use CodeBlocks software for learning C++ then you can look into this link. CodeBlocks is a very beginner friendly software for learning the language. - https://www.youtube.com/watch?v=KTrQyyVmHDc\n
\n\n### 3) The cliched first - executing HelloWorld.cppπŸŽ‰πŸŽ‰πŸŽ‰\n\nHello World\n\n\n##### First thing's first, let us look into how you will run a program in c++\n##### Open the text editor of your choice. Create a folder called MyCode and go into the folder. Within this folder create a file called HelloWorld.cpp\n\n
\n\n### QUIZ: What is the file extension used when we write c++ code? The answer to this question is .cpp \n\n##### Now copy and paste the below code into HelloWorld.cpp. Please save the file once you have pasted the code, because if you forget, then in case the file is closed, all your work is lost.\n
\n\n### CODE\n\n\n#include \n\nint main() {\n std::cout << \Hello, World!\";\n return 0;\n}\n\n\n### Here are the steps to run a C++ code via terminal:\n
\n\n##### Open the terminal application on your computer.Navigate to the directory where your C++ code is saved.\n
\n\n##### Since C++ uses a compiler, we must first compile the program before executing it. Command to compile the code is :\n\n\ng++ -o hello HelloWorld.cpp\n\n##### Here, hello is the name of the file obtained after execution. I have named my file hello, but you can change it as per your liking.\n
\n
\n\n##### Replace HelloWorld.cpp with the name of the file you want to execute.\n
\n\n##### Now after compilation you must execute the file with the following command: \n\n\n./hello\n\n##### Replace hello with the name you have given during compilation. \n
\n\n#\n## Congratulation on executing your very first C++ program πŸ‘πŸ‘πŸ‘\n\n#### We have reached the end of this tutorial. But if you wish to explore further into C++, you can use the below youTube tutorial to learn :\n\n##### https://www.youtube.com/watch?v=ZzaPdXTrSb8"

UVCE,
K. R Circle,
Bengaluru 01