C++ is still a powerful programming language, despite the advent of various modern languages. Learning C++ enables the learner to easily perceive the most trending programming languages The Programming C++ journey facilitates the learners to understand the functional programming model and Object-oriented programming model and to identify which model to apply under what circumstances. Each learning path presents adequate chances for writing programs and identifying & fixing errors. As the learners keep gaining knowledge, they will demonstrate coding skills in lab practice, capstone projects, and final assessments. This journey is a blend of all the fundamentals and the new features of C++. The intent here is to provide the learners with all the most crucial information in one place to write correct, portable, professional-quality code. The first track of this journey offers the learners a complete understanding of every fundamental feature of the C++ programming language. In the second track, the focus shifts to core programming in C++, where the learners will recognize the significance of object-oriented programming. The journey concludes with the exploration of advanced C++ topics like File Handling, Data Structures, First-class functions, Templates, C++ Lambdas, Graphics, and the development of a simple gaming application.
In this Skillsoft Aspire track of the Programming C++ journey, the focus will be on the exploration of advanced C++ topics like File Handling, Data Structures, First-class functions, Templates, C++ Lambdas, Graphics, and the development of a simple gaming application.
Since its inception about three and a half decades ago, the C++ language has constantly reinvented itself and kept pace with changing times. This constant reinvention has kept C++ relevant for many use cases today. Explore the history of C++ and the difference between classic C++ and modern C++. Discover the compilation process of C++ and the role of the pre-processor, the compiler, and the linker. Look at the variety of compilers available for C++ and the C++ standard library. Finally, learn how to install C++ and write, compile, and run simple C++ programs. You will work with the MSYS2 collection of utilities and familiarize yourself with the VSCode integrated development environment (IDE). By the end of this course, you will have a solid foundation of the basics of C++ and a good sense of why C++ language features evolved the way they did.
Variables and datatypes are basic building blocks of any programming language. This is especially true for C++, which has a very complex type system. In this course, we will be reintroducing constructs from C and emphasize the differences between variables and datatypes in C++ relative to those in C. Start by considering the difference between the initialization and declaration of a variable. Explore arithmetic, relational, and logical operators and make use of the C++ boolean type. Finally, explore strings in C++ and utilize many of the powerful methods provided by the String class, which are available for use on all string objects. Upon completion, you'll be able to distinguish between variable declaration and initialization, initialize variables using functional, assignment, and braced syntax, and leverage the C++ boolean type and the std::string class.
C++ supports many different programming paradigms including object-oriented programming, functional programming, and template programming. As a result, the C++ type system is quite complex and it can get quite complicated to figure out the correct type for a variable Learn how to use the auto keyword to request that the compiler infer the type of a variable from its context. Discover how to use the typeid() function to get a type info object for every variable and to verify that the auto keyword has worked as intended. Next, explore enums and identify the differences between C-style and C++-style enums. Learn about input and output streams, in particular the cin and cout streams used in C++. Finally, discover how to use I/O manipulators to control the appearance of objects on these streams. After comleting this coures, you'll be able to utilize the auto keyword to infer the type of a variable and deploy IO manipulators to correctly format data on input and output streams.
Control structures in C++ are syntactically very similar to those in C, but with some important differences. This course will help you learn to use control structures in C++ and better understand how they differ from those in C. You will start this course by going over the control structures available in C++. You will then move on to working with vectors and iterators over vectors, which are important parts of the standard template library. Finally, you will work with switch statements and learn some tips and tricks related to working with cases based on strings. Upon completion, you'll be able to use variables in the condition of an if-block to restrict its scope, and use switch statements with hash functions and the STL map object to switch based on the values of a string.
One of the many differences between modern C++ and classic C++ is the presence of range-based for loops. These were added to the standard in C++11 and allow for loops to iterate easily over a container and reduce the risk of off-by-one errors. They also eliminate the need for an integer index variable to index into a container. Start this course by reviewing how for loops work to iterate over arrays. Create arrays with different numbers of dimensions and iterate over the dimensions using nested for loops. Discover how to use containers from the standard template library to experiment with maps and vectors. Explore the use of the cbegin(), cend(), rbegin(), rend(), crbegin(), and crend() functions. Finally, use range-based for loops and explore the use of the debugger in this context. You will also note the important differences between value type loop variables in for loops and reference type variables.
As a superset of C, C++ also has support for pointer variable types that point to specific memory locations. While the pointer types function similarly, the terms related to pointer variables have evolved from C to C++ and modern C++, as you will see in this course. Begin this course by creating pointers to values and arrays. You will then move to the use of the nullptr keyword, and see how it differs from the NULL value used in C. Finally, you will create pointers to vectors and maps. After completion of this course, you'll have a solid foundation of using pointers to stack memory locations in C++ and create pointers to vectors and maps.
C++, like C, has powerful support for memory allocation and deallocation. In the world of C, these operations are performed using malloc() and free(), which are not to be used in the C++ world. In classic C++, memory allocation and deallocation are performed using the new and delete operators. You will begin this course by understanding the new and delete keywords, and note how these lead to the invocation of the underlying constructors and destructors on whatever objects are being worked with. In contrast, the C versions, that is, malloc() and free(), do not invoke constructors or destructors. You will then move on to the use of array new and array delete, which is how the new and delete followed by square brackets are referred to. Finally, you will look at the differences between const pointers and pointers to consts.
Dynamic memory allocation and deallocation in C are performed using malloc() and free(). In classic C++, dynamic memory allocation and deallocation are performed using new and delete, and array new and array delete. In modern C++, it's smart pointers that take over. Begin this course by examining the idea behind smart pointers. You will then explore the different types of smart pointers, including unique pointers, shared pointers, and weak pointers. Discover why weak pointers are required in some cases to avoid circular references that can cause memory leaks. After completing this course, you'll be able to use smart pointer objects, leverage RAII to use shared, unique, and weak pointers, and avoid circular references using weak pointers.
C++ supports a variable type known as the reference. You can think of references as being easier-to-use, lighter-weight versions of pointers. Begin by getting familiar with the syntax and semantics of references in C++, including the use of the & symbol to denote a reference type. Note some important differences between references and pointers, how references need to be assigned when they are created, how they cannot be reassigned or set to NULL, and how multiple references to the same underlying value are all effectively aliases for that value. Move on to declaring and using variables of reference type. Finally, learn about const references and experiment with different configurations of loops, where the loop variables are references, value types, and const references. Upon course completion, you'll be able to define and initialize variables of reference types, contrast pointers and references, and correctly use const references.
Functions remain an important construct for code modularization and reuse in C++, even though C++ is an object-oriented language. Learn how to use functions in C++, focusing on free functions, and examine the distinction between declaring a function, where you specify the function's signature, return type, and name; defining a function, where you create the body of a function; and invoking the function. Then, explore the semantics of passing parameters by value to C++ functions. Finally, compare pass-by-reference semantics to pass-by-value semantics and investigate the differences. Upon completion of this course, you will be able to use pass-by-value and pass-by-reference semantics in the context of function invocation in C++.
C++ allows you as the developer to specify default values for the input arguments into your functions, and supports function overloading. Both of these are powerful techniques for code reuse. Explore how to use default argument values for C++ functions, including important rules that govern such default values. Examine the semantics of return values from functions and learn how to avoid the dangling pointer problem. Discover function overloading, learn how to split the declaration and implementation of a function across header and implementation files, and learn the correct way of importing these header files into code to invoke that function. Upon completion, you'll be able to specify default values for function arguments, overload functions based on input arguments and const, and split functions across .h and .cpp files.
C++ is an object-oriented programming (OOP) language wherein developers model real-world entities, create classes, and instantiate objects of classes. In this course, learn how the object-oriented programming approach functions at a conceptual level. Discover how class act effectively as blueprints and explore member variables. Then, examine class definitions in your C++ programs and practice instantiating objects of those classes. Next, learn how to perform simple operations on those objects, invoke methods on them, and access and examine their member variables. Finally, learn how to modularize your code and declare a class in the header file. After completion of the course, you'll be able to define classes, instantiate objects, and split class implementation and declaration.
A constructor is a special method of a class invoked when an object of that class is created. Constructors have a fair bit of complexity, and can be chained to achieve code reuse and marked as explicit to avoid unexpected type promotions and object creation. In this course, examine the important aspects of constructor syntax, such as specifying default arguments and correctly using initialization lists. Next, learn how to chain constructors and retain most of the code functionality in one constructor. Finally, learn how constructors might be invoked automatically by the C++ runtime to create objects for method invocations. After completion of the course, you'll be able to correctly initialize variables using initialization lists, connect constructors using constructor chaining, and create structs.
When a member function is invoked on a particular object, that object is known as the receiver. Within the body of the member function, you can access the member variables of the receiver using the "this" pointer. In this course, discover how the this pointer works and practice using it to access states. Next, learn about constness in object-oriented programming and the restrictions for what such methods can do. Finally, learn how to use the mutable keyword to mitigate constness. After completion of the course, you'll be able to access member variables from within member functions, create const and non-const objects and functions, and use the mutable specification to identify states that can be changed without changing the meaning of the object.
Static means something different in C++ compared to C. In C, static refers to a storage class for storing specific types of variables. In C++, static refers to member functions and variables associated with the entire class. In this course, learn how to mark a member variable within a class as static, initialize a static member variable, and access it from methods within and outside the class. Next, discover how static member functions can be used for class-level behavior. Finally, learn how to define and use a destructor. After completion of the course, you'll be able to create and use static variables, access them using the scope resolution operator, and instantiate and deallocate a pointer in constructors and destructors.
A copy constructor in C++ classes is a specialized method used to create an object from another object of the same class. Other specialized C++ methods include nested classes and namespaces, which organize different classes in a logical and coherent manner while avoiding name conflicts. In this course, learn how to specify and use a copy constructor. Next, discover how classes and functions can be marked as friends. Finally, examine how nested classes can be defined and used in C++ and practice using namespaces to modularize your code. After completion of the course, you'll be able to create and implement a custom copy constructor, access private variables using friend functions and classes, and store functions and classes in namespaces.
Inheritance is a powerful, object-oriented language construct in which one class can be related to another class using an is-a relationship. Using inheritance, you can construct complicated class hierarchies in which one class is a parent or a base of another class. Is-a relationships are a great way of performing object-oriented design and are complemented by has-a relationships, which are implemented using composition, rather than inheritance. Explore inheritance relationships by setting up an inheritance hierarchy in C++ and specifying one class as the parent of another class. Then discover how member variables and methods are accessible from the drive class, as well as from external code. Finally, investigate base class access specifiers, and find out how they work with member access specifiers. When you're finished, you'll clearly understand how to use inheritance for is-a relationships and how to identify uses for private inheritance.
The order in which constructors and destructors are invoked on an object of a derived class in an inheritance hierarchy is a very important topic. Constructors are invoked in order from the top-most (most base-level) class, down to the most derived class. Destructors are invoked in the reverse order. Explore how constructors work in an inheritance hierarchy, the order in which the base and derived class constructors are invoked, and how initialization lists need to be used in the derived class. Discover how to use copy constructors and destructors in the context of inheritance. Learn how to set up an inheritance hierarchy for polymorphism. Finally, practice using objects in an inheritance hierarchy with variables of pointer and reference types. When you finish this course, you will have a solid foundation in constructors, destructors, and inheritance, setting the stage for runtime polymorphism and dynamic method dispatch.
Inheritance forms the basis for polymorphism, specifically runtime polymorphism, which is a powerful object-oriented programming construct. Runtime polymorphism involves a pointer or a reference of the base class type holding an object of the derived class. The beauty of runtime polymorphism is that when virtual methods are invoked on this pointer, the derived class versions are executed. You will start this course by defining name hiding and how most methods on C++ objects are, by default, statically dispatched. You will then learn about polymorphism and dynamic dispatch, which is accomplished using the virtual keyword. Finally, you will learn how the ‘override' and 'final' specifications can be used to achieve precise semantics and reduce the scope of bugs and typos in your C++ programs.
Pure virtual functions and interfaces are very powerful tools in object-oriented programming, and interface-driven programming is a great way of splitting up work across different developers on a large project. You will start this course by considering why your destructors should be marked as virtual in the base class if you have an inheritance hierarchy. You'll see the harmful effects of not using virtual destructors in an inheritance hierarchy and the problems with object slicing. You will also learn why it is preferable to have variables of reference types to the base class rather than the value types. You will then move to some finer points of working with virtual methods, such as, the inadvisability of using default parameters because these are statically bound. Finally, you will master the syntax and semantics of pure virtual functions and learn how a class that contains even one pure virtual function becomes an abstract class that cannot be instantiated directly.
C++ allows multiple inheritance, which means that one class can have more than one base. C++ also has some powerful mechanisms for dealing with edge cases such as the diamond hierarchy. You will start this course by learning the precise syntax which is required to implement multiple inheritance in C++, specifically, how it's important to have both base class access specifiers marked independently. You will then move on to the topic of a diamond inheritance hierarchy, in which the grandchild-level derived class has two parents, both of which inherit from the common, grandparent level base class. Finally, you will see how dynamic casts work in the context of an inheritance hierarchy, how these are a lot safer than static casts, and how they return a null value on failure when used with pointers but they throw an exception on failure when used with references.
Operator overloading is an unusual language feature that is quite important in C++, enabling you to specify implementations of the standard operators for your user-defined types. You can overload a wide variety of operators, each having a standard meaning for built-in types that can be mimicked in custom types. If used correctly, this can lead to natural, elegant-looking code. Begin this course by learning how to overload simple operators and explore the restrictions around overloading operators. Then, discover how to overload operators as member functions of a class, providing easy access to the internal state of the object. Finally, focus on identifying situations where the member function implementation will not work and investigate best practices of operator overloading.
The stream insertion and extraction operators are often overloaded because they provide a convenient way to read objects in and write objects out to standard IO. The copy assignment operator is even more crucial because of how important it is in correctly freeing up resources held by an object. In this course, learn how to implement the correct overloads of the insertion and extraction operators and why these are invariably implemented as non-member functions. Then, move on to correctly overloading the copy assignment operator and using standard formats to ensure that resource cleanup occurs exactly once. Finally, find out how the copy-and-swap idiom provides a way to use the std::swap function to implement the copy assignment operator in a manner that is exception-safe. This idiom leads to an elegant implementation that is not only less complex, but also more robust.
Some of the most commonly overloaded operators include binary arithmetic operators, used in operations such as a + b; compound assignment operat+B30ors of the form a+= b; and the prefix and postfix operators of the form a++. In this course, discover how to overload binary arithmetic operators appropriately, so that they support correct semantics in chaining. Learn how to overload compound assignment operators, such as +=. Explore how the C++ compiler differentiates between the pre and post increment operators and how these operators work in various edge cases. When you complete this course, you will be able to confidently leverage std_rel_ops by overloading relational operators.
Template metaprogramming is a powerful computer science technique used to achieve code reuse and some incredibly elegant architectures. In C++, template metaprogramming is achieved via template functions and classes that are instantiated at compile-time, not at runtime. In this course, learn how to define and instantiate function templates to effectively provide compile-time polymorphism. Then, explore how template definitions can make assumptions about the template parameters. Finally, learn how to define and use templates with pointer and reference types to provide function overloading.
Template programming is very powerful and can also get quite complicated. In this course you will tackle some of those complications by using multi-value function templates. Learn how decl_type and auto keywords can be used to allow type inference on the return type of a function. Work with default arguments for template parameters and see how this can lead to mismatches if done carelessly. Finally, define and specify non-type template parameters and explore the relationship between the values of those parameters and the compiler.
Class templates are a way of reusing code for classes parameterized by types of internal state variables, just as function templates are a way of reusing code for functions parameterized by the types of input arguments and return types. In this course you will discover how to define and instantiate class templates, along with common uses of templated classes. Learn how to use the braced initialization list constructor and explore how the compiler provides this special construct so that container objects can be initialized from a list of values. Finally, investigate partial and full template specializations, and how partial specializations can be used to correctly deal with pointer types.
References are an important part of C++, and a little-known fact about references is that there are actually two types of references: l-value and r-value. In this course, explore those two reference types by learning how to use the syntax and semantics of r-value references to extend the lifespan of transient values. Then, implement the move assignment operator and move constructor, using r-value references as their input arguments, to reduce the number of unnecessary copies created in your C++ programs. Finally, work with Resource Acquisition Is Initialization (RAII) to use smart pointers as a way to bypass complex rules, such as the rule of three and the rule of five, allowing you to follow the simplest rule of all - the rule of 0.
Final Exam: Object-oriented Concepts in C++ will test your knowledge and application of the topics presented throughout the Object-oriented Concepts in C++ track of the Skillsoft Aspire Programming in C++ Journey.
C++ structures different file stream classes into an inheritance hierarchy. Input and output (I/O) operations are performed in C++ through streams, which act as intermediaries between the program and I/O devices, allowing programmers to not focus on how the actual device works. In this course, learn about the different classes and objects for C++ stream handling. Next, discover how to read data from files using objects of the ifstream class. Finally, practice writing out data to files using objects of the ofstream class, including writing out simple integers, floats, strings, and structured data. Upon completion, you'll be able to enumerate C++ file stream classes, read data from files using ifstream, and write data to files using ofstream.
The insertion and extraction operators are very commonly overloaded in custom C++ classes. Such overloads make it easy to write objects out to cout or to file and read objects in from cin or a file. In this course, learn how to correctly overload the insertion and extraction operators for streams and explore different aspects of text data streaming. Next, work with different file open modes, including read, write, append, and ate modes. Finally, practice using the stream state bits contained within stream objects. Upon completion, you'll be able to leverage file open modes, check stream state bits, and correctly use the std::filesystem API.
Exceptions are the most popular form of error handling and the try-catch block is superior to all other error handling mechanisms because it forces the invoking function to manage the errors. In this course, learn how exceptions are thrown and caught. Next, practice creating and using custom exception objects and discover why exceptions must be caught by reference. Finally, explore object slicing results, the semantics and limitations of the noexcept keyword, and the pitfalls of exceptions that occur within constructors. Upon completion, you'll be able to correctly throw and handle exceptions using try/catch blocks, enumerate semantics and limitations of the noexcept keyword, and mitigate problems related to exceptions thrown during the construction of an object.
In C++, containers are structures that store collections of other objects known as elements. Sequence containers are used to store elements of the same type sequentially in a linear arrangement, and associative containers store elements in the form of key-value pairs. In this course, work with basic sequence containers called arrays, as well as vectors. Next, learn about forward lists and lists, which are sequence data structures that allow constant time insert and erase operations. Finally, discover how to work with deques (double-ended queues) and container adapters, including stacks, queues, and priority queues. Upon completion, you'll be able to contrast sequence and associative containers, enumerate properties, and correctly use stacks, queues, and priority queues.
Associative containers provide fast lookup in O(log n) time by associating each entry with a key. Sets and maps are both associative containers. Algorithms are classes that support container-agnostic operations performed on containers. In this course, learn how to create sets and iterate over them, as well as use ordered and unordered multisets. Next, practice creating maps and indexing into them using keys, as well as inserting key-value pairs into maps. Finally, examine how random access of elements is faster with unordered maps compared to ordered maps, and explore various STL algorithms. Upon completion, you'll be able to differentiate between sequence and associative containers, leverage STL algorithms, and instantiate and use sets, multisets, maps, and multimaps.
While C++ is considered an object-oriented language, it provides support for functional programming, including support for first-class functions in three manners: function pointers, function objects, and lambdas. In this course, discover the complexity of C-style function pointers by creating them and invoking functions through them. Next, learn about the various features and uses of function pointers and how to accept functions as input arguments and return functions from a higher-order function. Finally, examine function objects (functors) and use them to overload the call operator, instantiate objects, and use the overloaded call operator. Upon completion, you'll be able to list the properties of C++ first-class functions, create function pointers, return functions from a higher-order function, and define and invoke a functor.
In C++, a lambda expression is an ad-hoc, locally scoped function object that offers a function definition syntax. Lambdas can be stored in variables and invoked like function objects or function pointers, but lambdas go further by supporting context capture. In this course, learn how to define and invoke lambda functions and pass and return input arguments to and from lambdas using the Standard Template Library (STL) algorithms. Next, explore how context capture works in lambdas and implement closures. Finally, work with context capture to specify captured variables and whether the capture is by copy or by reference. Upon completion, you'll be able to define and invoke a lambda function, perform context capture by value and by reference, and define closures inside class methods.
Simple and Fast Multimedia Library (SFML) is a cross-platform, software development library used for designing gaming applications, providing features like audio, graphics, and a network, which together allow you to build the complete multimedia experience. Begin by creating and managing windows that can hold multimedia gaming applications. Learn how to keep a game constantly running and updated using a game loop. Next, explore event handling in SFML, including mouse clicks, scrolls, keypress events, resize, and focus events. Finally, use the Graphics module in SFML to draw graphical entities, like geometric shapes, to the screen and configure the properties of these entities. When you have completed this course, you will have the foundational knowledge to create and render graphical entities within SFML windows.
Multimedia applications require a number of different entities to come together - graphical entities, animations, views, audio, and networking. SFML's modules allow you to incorporate all of these in an easy and intuitive manner to build fully-fledged gaming applications. First, explore graphics entities such as textures and sprites to specify backgrounds and interact with different textures. Next, use vertex arrays to create and transform shapes by moving, rotating, and scaling entities. Then, create animations and play sounds using SFML. Finally, bring everything together to build a multimedia game of Tic-Tac-Toe, containing the logic for win-lose-draw. After completing this course, you will have the skills and ability to use SFML constructs to develop gaming applications.