HANDOUTS 3

Cards (47)

  • C++ - is a general-purpose programming language that was developedas an enhancement of the C language to include object-orientedparadigm. It is an imperative and a compiled language.
  • C++ - It was developed by Bjarne Stroustrup at Bell Labs in 1983 as an extension of the C programming language.It wasdeveloped by Bjarne Stroustrup at Bell Labs in 1983 as anextension of the C programming language.
  • Object-Oriented Programming: allowing developers to create classes and objects and to define methods and properties for these objects.
  • Templates: allow developers to write genericcode that can work with any data type, making it easier towrite reusable and flexible code.
  • Standard Template Library (STL): provides a wide range of containers and algorithms for working with data, making it easier to write efficient and effective code.
  • Exception Handling: C++ provides robust exception handling capabilities, making it easier to write code that can handle errors and unexpected situations.
  • Simple: It is a simple language in the sense that programs canbe broken down into logical units and parts, has a richlibrary support and a variety of data-types.
  • Machine Independent but Platform Dependent: A C++ executables not platform-independent (compiled programs on Linux won’t run on Windows), however they are machine independent.
  • Mid-level language: It is a mid-level language as we can doboth systems-programming (drivers, kernels, networking etc.)and build large-scale user applications (Media Players,Photoshop, Game Engines etc.)
  • Rich library support: Has a _____(Bothstandard ~ built-in data structures, algorithms etc.) as well3rd party libraries (e.g. Boost libraries) for fast and rapid development.
  • Speed of execution: Since, it is a compiled language, and also hugely procedural. Newer languages have extra in-built default features such as garbage-collection, dynamic typing etc. which slow the execution of the program overall. Since there is no additional processing overhead like this in C++, it is blazing fast
  • Pointer and direct Memory-Access: which aids users to directly manipulate storage address. This helps in doing low-level programming (where one might need to have explicit control on the storage of variables).
  • Object-Oriented: One of the strongest points of the language which sets it apart from C. ______support helps C++to make maintainable and extensible programs. i.e. Large-scale applications can be built. Procedural code becomes difficult to maintain as code-size grows.
  • Compiled Language: C++ is a _________, contributing to its speed.
  • Applications of C++
    Operating Systems & Systems Programming. e.g. Linux-based OS(Ubuntu etc.)
    Browsers (Chrome & Firefox)
    Graphics & Game engines (Photoshop, Blender, Unreal-Engine)
    Database Engines (MySQL, MongoDB, Redis etc.)
    Cloud/Distributed Systems
  • Object-Oriented Programming: means that it allows you to define classes and objects to model real-world entities and their behavior.
  • Strong Type System: which means that variables have a specific type and that type must be respected in all operations performed on that variable.
  • Low-level Access: C++ provides _______ to system resources, which makes it a suitable choice for system programming and writing efficient code.
  • Standard Template Library (STL): provides a large set of pre-written algorithms and data structures that can be used to simplify your code and make it more efficient.
  • Cross-platform Compatibility: C++ can be compiled and run onmultiple platforms, including Windows, MacOS, and Linux, makingit a versatile language for developing cross-platformapplications.
  • Performance: C++ is a compiled language, which means that code istransformed into machine code before it is executed. This canresult in faster execution times and improved performancecompared to interpreted languages like Python.
  • Memory Management: C++ requires manual memory management, whichcan lead to errors if not done correctly. However, this alsoprovides more control over the program’s memory usage and canresult in more efficient memory usage.
  • Syntax: C++ has a complex syntax that can be difficult to learn,especially for beginners. However, with practice and experience,it becomes easier to understand and work with.
  • Performance: C++ is a compiled language, which means that itscode is compiled into machine-readable code, making it one of thefastest programming languages.
  • Object-Oriented Programming: C++ supports object-orientedprogramming, which makes it easier to write and maintain large,complex applications.
  • Standard Template Library (STL): The STL provides a wide range ofalgorithms and data structures for working with data, making iteasier to write efficient and effective code.
  • Machine Independent: C++ is not tied to any hardware orprocessor. If the compiler compiles the program in the system, itwill be able to run no matter what the hardware is.
  • Large Community: C++ has a large, active community of developersand users, providing a wealth of resources and support forlearning and using the language.
  • Steep Learning Curve: C++ can be challenging to learn, especiallyfor beginners, due to its complexity and the number of conceptsthat need to be understood.
  • Verbose Syntax: C++ has a verbose syntax, which can make codelonger and more difficult to read and maintain.
  • Error-Prone: C++ provides low-level access to system resources,which can lead to subtle errors that are difficult to detect andfix.
  • #include
    • This is a preprocessor directive. The #include directive tells the compiler to include the content of a file in the source code
    .• For example, #include<iostream> tells the compiler to include the standard iostream file which contains declarations of all the standard input/output library functions.
  • using namespace std•
    This is used to import the entity of the std namespace into thecurrent namespace of the program. The statement using namespacestd is generally considered a bad practice. When we import anamespace we are essentially pulling all type definitions intothe current scope.
  • int main() { }
    • A function is a group of statements that are designed to performa specific task. The main() function is the entry point of everyC++ program, no matter where the function is located in theprogram.
  • cout<<“Hello World”;
    • std::cout is an instance of the std::ostream class, that is usedto display output on the screen. Everything followed by thecharacter << in double quotes ” ” is displayed on the outputdevice. The semi-colon character at the end of the statement isused to indicate that the statement is ending there.
  • return 0•
    This statement is used to return a value from a function andindicates the finishing of a function. This statement isbasically used in functions to return the results of theoperations performed by a function.
  • Indentation•
    As you can see the cout and the return statement have beenindented or moved to the right side. This is done to make thecode more readable. We must always use indentations and commentsto make the code more readable.
  • Omitting Namespace•
    You might see some C++ programs that runs without the standardnamespace library. The using namespace std line can be omittedand replaced with the std keyword, followed by the :: operatorfor some objects.
  • C++ Output (Print Text)• The cout object, together with the << operator, is used to outputvalues/print text.
  • New Lines•
    To insert a new line, you can use the \n character