diff --git a/src/data/roadmaps/cpp/content/100-introduction/102-c-vs-cpp.md b/src/data/roadmaps/cpp/content/100-introduction/102-c-vs-cpp.md index 9134d8010..737776649 100644 --- a/src/data/roadmaps/cpp/content/100-introduction/102-c-vs-cpp.md +++ b/src/data/roadmaps/cpp/content/100-introduction/102-c-vs-cpp.md @@ -34,7 +34,7 @@ int main() { class HelloWorld { public: void printHello() { - std::cout << "Hello, World!" << std::endl; + std::cout << "Hello, World!\n"; } }; diff --git a/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md b/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md index 8d6633b01..ea35bb155 100644 --- a/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md +++ b/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md @@ -10,7 +10,7 @@ The first program that most people learn to write in any programming language is #include <iostream> int main() { - std::cout << "Hello, World!" << std::endl; + std::cout << "Hello, World!\n"; return 0; } ``` @@ -40,7 +40,7 @@ int main() { To output text to the console, we use the `std::cout` object and the insertion operator `<<`. In the "Hello, World!" example, we used the following line to print "Hello, World!" to the console: ```cpp -std::cout << "Hello, World!" << std::endl; +std::cout << "Hello, World!\n"; ``` - `std`: This is the namespace where C++ standard library entities (classes and functions) reside. It stands for "standard" and is an abbreviation for the Standard Template Library (STL). - `std::cout`: The standard "character output" stream that writes to the console diff --git a/src/data/roadmaps/cpp/content/101-setting-up/index.md b/src/data/roadmaps/cpp/content/101-setting-up/index.md index d66ffab97..12bbfad33 100644 --- a/src/data/roadmaps/cpp/content/101-setting-up/index.md +++ b/src/data/roadmaps/cpp/content/101-setting-up/index.md @@ -38,7 +38,7 @@ Create a new file called `main.cpp` within your project and include this code: #include <iostream> int main() { - std::cout << "Hello, World!" << std::endl; + std::cout << "Hello, World!\n"; return 0; } ``` diff --git a/src/data/roadmaps/cpp/content/102-basic-operations/101-logical-operators.md b/src/data/roadmaps/cpp/content/102-basic-operations/101-logical-operators.md index 35dbc5c2f..850a04f60 100644 --- a/src/data/roadmaps/cpp/content/102-basic-operations/101-logical-operators.md +++ b/src/data/roadmaps/cpp/content/102-basic-operations/101-logical-operators.md @@ -13,7 +13,7 @@ C++ provides the following logical operators: ```cpp int a = 5, b = 10; if (a > 0 && b > 0) { - std::cout << "Both values are positive." << std::endl; + std::cout << "Both values are positive.\n"; } ``` - **OR Operator (||)** @@ -25,7 +25,7 @@ C++ provides the following logical operators: ```cpp int a = 5, b = -10; if (a > 0 || b > 0) { - std::cout << "At least one value is positive." << std::endl; + std::cout << "At least one value is positive.\n"; } ``` @@ -38,7 +38,7 @@ C++ provides the following logical operators: ```cpp int a = 5; if (!(a < 0)) { - std::cout << "The value is not negative." << std::endl; + std::cout << "The value is not negative.\n"; } ``` @@ -48,7 +48,7 @@ Using these operators, you can create more complex logical expressions, for exam int a = 5, b = -10, c = 15; if (a > 0 && (b > 0 || c > 0)) { - std::cout << "At least two values are positive." << std::endl; + std::cout << "At least two values are positive.\n"; } ``` diff --git a/src/data/roadmaps/cpp/content/103-functions/100-lambda.md b/src/data/roadmaps/cpp/content/103-functions/100-lambda.md index 69a03f86a..ca5dd805b 100644 --- a/src/data/roadmaps/cpp/content/103-functions/100-lambda.md +++ b/src/data/roadmaps/cpp/content/103-functions/100-lambda.md @@ -25,7 +25,7 @@ Here are a few examples to demonstrate the use of lambda functions in C++: ```cpp auto printHello = []() { - std::cout << "Hello, World!" << std::endl; + std::cout << "Hello, World!\n"; }; printHello(); // Output: Hello, World! ``` diff --git a/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/101-shared-ptr.md b/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/101-shared-ptr.md index 7f9962a83..5657ca051 100644 --- a/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/101-shared-ptr.md +++ b/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/101-shared-ptr.md @@ -14,8 +14,8 @@ Here's an example of how to use `shared_ptr`: class MyClass { public: - MyClass() { std::cout << "Constructor is called." << std::endl; } - ~MyClass() { std::cout << "Destructor is called." << std::endl; } + MyClass() { std::cout << "Constructor is called.\n"; } + ~MyClass() { std::cout << "Destructor is called.\n"; } }; int main() { @@ -26,11 +26,11 @@ int main() { // create another shared pointer and initialize it with the previously created pointer std::shared_ptr<MyClass> ptr2 = ptr1; - std::cout << "Inside the inner scope." << std::endl; + std::cout << "Inside the inner scope.\n"; // both pointers share the same object, and the reference counter has been increased to 2 } - std::cout << "Outside the inner scope." << std::endl; + std::cout << "Outside the inner scope.\n"; // leaving the inner scope will destroy ptr2, and the reference counter is decremented to 1 // the main function returns, ptr1 goes out of scope, and the reference counter becomes 0 diff --git a/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/102-uniqe-ptr.md b/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/102-uniqe-ptr.md index 709f19c26..ae43784aa 100644 --- a/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/102-uniqe-ptr.md +++ b/src/data/roadmaps/cpp/content/105-pointers-and-references/smart-pointers/102-uniqe-ptr.md @@ -35,9 +35,9 @@ int main() { std::unique_ptr<int> p2 = std::move(p1); // Ownership is transferred from p1 to p2 if (p1) { - std::cout << "p1 owns the object" << std::endl; + std::cout << "p1 owns the object\n"; } else if (p2) { - std::cout << "p2 owns the object" << std::endl; + std::cout << "p2 owns the object\n"; } return 0; @@ -52,7 +52,7 @@ int main() { struct MyDeleter { void operator()(int* ptr) { - std::cout << "Custom Deleter: Deleting pointer" << std::endl; + std::cout << "Custom Deleter: Deleting pointer\n"; delete ptr; } }; diff --git a/src/data/roadmaps/cpp/content/106-structuring-codebase/101-code-splitting/index.md b/src/data/roadmaps/cpp/content/106-structuring-codebase/101-code-splitting/index.md index 4a9323506..a5270117c 100644 --- a/src/data/roadmaps/cpp/content/106-structuring-codebase/101-code-splitting/index.md +++ b/src/data/roadmaps/cpp/content/106-structuring-codebase/101-code-splitting/index.md @@ -33,7 +33,7 @@ Example of a source file: #include <iostream> void Example::printMessage() { - std::cout << "Hello, code splitting!" << std::endl; + std::cout << "Hello, code splitting!\n"; } ``` diff --git a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/index.md b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/index.md index a76f419e3..aa185be47 100644 --- a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/index.md +++ b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/index.md @@ -15,7 +15,7 @@ Here's an example in C++ demonstrating dynamic polymorphism. class Shape { public: virtual void draw() { - std::cout << "Drawing a shape" << std::endl; + std::cout << "Drawing a shape\n"; } }; @@ -23,7 +23,7 @@ public: class Circle : public Shape { public: void draw() override { - std::cout << "Drawing a circle" << std::endl; + std::cout << "Drawing a circle\n"; } }; @@ -31,7 +31,7 @@ public: class Rectangle : public Shape { public: void draw() override { - std::cout << "Drawing a rectangle" << std::endl; + std::cout << "Drawing a rectangle\n"; } }; diff --git a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/virtual-tables.md b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/virtual-tables.md index b89591e63..952cf0db0 100644 --- a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/virtual-tables.md +++ b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/101-dynamic-polymorphism/virtual-tables.md @@ -12,22 +12,22 @@ Let's consider the following example: class Base { public: virtual void function1() { - std::cout << "Base::function1" << std::endl; + std::cout << "Base::function1\n"; } virtual void function2() { - std::cout << "Base::function2" << std::endl; + std::cout << "Base::function2\n"; } }; class Derived : public Base { public: void function1() override { - std::cout << "Derived::function1" << std::endl; + std::cout << "Derived::function1\n"; } void function3() { - std::cout << "Derived::function3" << std::endl; + std::cout << "Derived::function3\n"; } }; diff --git a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/index.md b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/index.md index ef4cc7863..e6720cdb4 100644 --- a/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/index.md +++ b/src/data/roadmaps/cpp/content/107-structures-and-classes/101-oop/index.md @@ -13,7 +13,7 @@ public: int age; void bark() { - std::cout << name << " barks!" << std::endl; + std::cout << name << " barks!\n"; } }; ``` @@ -47,7 +47,7 @@ public: } void bark() { - std::cout << name << " barks!" << std::endl; + std::cout << name << " barks!\n"; } }; ``` @@ -62,14 +62,14 @@ Inheritance is the concept of deriving new classes from existing ones, which ena class Animal { public: void breathe() { - std::cout << "I can breathe" << std::endl; + std::cout << "I can breathe\n"; } }; class Dog : public Animal { public: void bark() { - std::cout << "Dog barks!" << std::endl; + std::cout << "Dog barks!\n"; } }; ``` @@ -90,21 +90,21 @@ Polymorphism allows you to use a single interface to represent different types. class Animal { public: virtual void makeSound() { - std::cout << "The Animal makes a sound" << std::endl; + std::cout << "The Animal makes a sound\n"; } }; class Dog : public Animal { public: void makeSound() override { - std::cout << "Dog barks!" << std::endl; + std::cout << "Dog barks!\n"; } }; class Cat : public Animal { public: void makeSound() override { - std::cout << "Cat meows!" << std::endl; + std::cout << "Cat meows!\n"; } }; ``` diff --git a/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/100-diamond-inheritance.md b/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/100-diamond-inheritance.md index 136b45012..5ed4139f8 100644 --- a/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/100-diamond-inheritance.md +++ b/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/100-diamond-inheritance.md @@ -12,28 +12,28 @@ To resolve this ambiguity, you can use virtual inheritance. A virtual base class class Base { public: void print() { - std::cout << "Base class" << std::endl; + std::cout << "Base class\n"; } }; class Derived1 : virtual public Base { public: void derived1Print() { - std::cout << "Derived1 class" << std::endl; + std::cout << "Derived1 class\n"; } }; class Derived2 : virtual public Base { public: void derived2Print() { - std::cout << "Derived2 class" << std::endl; + std::cout << "Derived2 class\n"; } }; class Derived3 : public Derived1, public Derived2 { public: void derived3Print() { - std::cout << "Derived3 class" << std::endl; + std::cout << "Derived3 class\n"; } }; diff --git a/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/index.md b/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/index.md index 03ab96510..5871224b4 100644 --- a/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/index.md +++ b/src/data/roadmaps/cpp/content/107-structures-and-classes/102-multiple-inheritance/index.md @@ -30,7 +30,7 @@ class Animal public: void eat() { - std::cout << "I can eat!" << std::endl; + std::cout << "I can eat!\n"; } }; @@ -40,7 +40,7 @@ class Mammal public: void breath() { - std::cout << "I can breathe!" << std::endl; + std::cout << "I can breathe!\n"; } }; @@ -50,7 +50,7 @@ class Dog : public Animal, public Mammal public: void bark() { - std::cout << "I can bark! Woof woof!" << std::endl; + std::cout << "I can bark! Woof woof!\n"; } }; diff --git a/src/data/roadmaps/cpp/content/108-exception-handling/101-exit-codes.md b/src/data/roadmaps/cpp/content/108-exception-handling/101-exit-codes.md index cb3e919a2..147225040 100644 --- a/src/data/roadmaps/cpp/content/108-exception-handling/101-exit-codes.md +++ b/src/data/roadmaps/cpp/content/108-exception-handling/101-exit-codes.md @@ -15,14 +15,14 @@ int main() { // Some code here... if (/*some error condition*/) { - std::cout << "An error occurred." << std::endl; + std::cout << "An error occurred.\n"; return 1; } // More code here... if (/*another error condition*/) { - std::cout << "Another error occurred." << std::endl; + std::cout << "Another error occurred.\n"; return 2; } @@ -40,7 +40,7 @@ void some_function() { // Some code here... if (/*some error condition*/) { - std::cout << "An error occurred." << std::endl; + std::cout << "An error occurred.\n"; std::exit(1); } diff --git a/src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/102-dynamic-cast.md b/src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/102-dynamic-cast.md index 622f17f5d..9475d53e9 100644 --- a/src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/102-dynamic-cast.md +++ b/src/data/roadmaps/cpp/content/109-language-concepts/101-type-casting/102-dynamic-cast.md @@ -10,14 +10,14 @@ Here is a basic example of how `dynamic_cast` can be used: class BaseClass { public: virtual void display() { - std::cout << "BaseClass" << std::endl; + std::cout << "BaseClass\n"; } }; class DerivedClass : public BaseClass { public: void display() { - std::cout << "DerivedClass" << std::endl; + std::cout << "DerivedClass\n"; } }; diff --git a/src/data/roadmaps/cpp/content/110-stl/101-iostream.md b/src/data/roadmaps/cpp/content/110-stl/101-iostream.md index 0d6f4c7aa..16ffad6e4 100644 --- a/src/data/roadmaps/cpp/content/110-stl/101-iostream.md +++ b/src/data/roadmaps/cpp/content/110-stl/101-iostream.md @@ -35,8 +35,8 @@ int main() { #include <iostream> int main() { - std::cerr << "An error occurred." << std::endl; - std::clog << "Logging information." << std::endl; + std::cerr << "An error occurred.\n"; + std::clog << "Logging information.\n"; return 0; } ``` diff --git a/src/data/roadmaps/cpp/content/110-stl/104-multithreading.md b/src/data/roadmaps/cpp/content/110-stl/104-multithreading.md index ef03c0e78..c42d9a9c4 100644 --- a/src/data/roadmaps/cpp/content/110-stl/104-multithreading.md +++ b/src/data/roadmaps/cpp/content/110-stl/104-multithreading.md @@ -13,7 +13,7 @@ To create a new thread, include the `<thread>` header file and create an instanc #include <thread> void my_function() { - std::cout << "This function is executing in a separate thread" << std::endl; + std::cout << "This function is executing in a separate thread\n"; } int main() { diff --git a/src/data/roadmaps/cpp/content/110-stl/105-ccontainers.md b/src/data/roadmaps/cpp/content/110-stl/105-ccontainers.md index 07276bf00..c85b07a83 100644 --- a/src/data/roadmaps/cpp/content/110-stl/105-ccontainers.md +++ b/src/data/roadmaps/cpp/content/110-stl/105-ccontainers.md @@ -64,7 +64,7 @@ int main() { m["one"] = 1; m["two"] = 2; - std::cout << "Map contains:" << std::endl; + std::cout << "Map contains:\n"; for (const auto &pair : m) { std::cout << pair.first << ": " << pair.second << std::endl; } @@ -87,7 +87,7 @@ int main() { um["one"] = 1; um["two"] = 2; - std::cout << "Unordered map contains:" << std::endl; + std::cout << "Unordered map contains:\n"; for (const auto &pair : um) { std::cout << pair.first << ": " << pair.second << std::endl; } diff --git a/src/data/roadmaps/cpp/content/111-templates/101-template-specialization/100-full.md b/src/data/roadmaps/cpp/content/111-templates/101-template-specialization/100-full.md index 98f2c13ea..11a15791d 100644 --- a/src/data/roadmaps/cpp/content/111-templates/101-template-specialization/100-full.md +++ b/src/data/roadmaps/cpp/content/111-templates/101-template-specialization/100-full.md @@ -19,7 +19,7 @@ template <typename T> class MyContainer { public: void print() { - std::cout << "Generic container." << std::endl; + std::cout << "Generic container.\n"; } }; @@ -28,7 +28,7 @@ template <> class MyContainer<int> { public: void print() { - std::cout << "Container for integers." << std::endl; + std::cout << "Container for integers.\n"; } }; diff --git a/src/data/roadmaps/cpp/content/111-templates/103-finae.md b/src/data/roadmaps/cpp/content/111-templates/103-finae.md index 6d23f9647..b097235ee 100644 --- a/src/data/roadmaps/cpp/content/111-templates/103-finae.md +++ b/src/data/roadmaps/cpp/content/111-templates/103-finae.md @@ -15,14 +15,14 @@ Here's an example that demonstrates SFINAE in action: template <typename T, typename = void> struct foo_impl { void operator()(T t) { - std::cout << "Called when T is not arithmetic" << std::endl; + std::cout << "Called when T is not arithmetic\n"; } }; template <typename T> struct foo_impl<T, std::enable_if_t<std::is_arithmetic<T>::value>> { void operator()(T t) { - std::cout << "Called when T is arithmetic" << std::endl; + std::cout << "Called when T is arithmetic\n"; } }; diff --git a/src/data/roadmaps/cpp/content/112-idioms/101-pimpl.md b/src/data/roadmaps/cpp/content/112-idioms/101-pimpl.md index 2229e8cd9..846ab73a9 100644 --- a/src/data/roadmaps/cpp/content/112-idioms/101-pimpl.md +++ b/src/data/roadmaps/cpp/content/112-idioms/101-pimpl.md @@ -32,7 +32,7 @@ class MyClass_Impl // the actual implementation public: void some_method() { - std::cout << "Implementation method called!" << std::endl; + std::cout << "Implementation method called!\n"; } }; diff --git a/src/data/roadmaps/cpp/content/112-idioms/102-crtp.md b/src/data/roadmaps/cpp/content/112-idioms/102-crtp.md index e09f1ed22..a573e565d 100644 --- a/src/data/roadmaps/cpp/content/112-idioms/102-crtp.md +++ b/src/data/roadmaps/cpp/content/112-idioms/102-crtp.md @@ -17,14 +17,14 @@ public: } void implementation() { - std::cout << "Default implementation in Base" << std::endl; + std::cout << "Default implementation in Base\n"; } }; class Derived1 : public Base<Derived1> { public: void implementation() { - std::cout << "Custom implementation in Derived1" << std::endl; + std::cout << "Custom implementation in Derived1\n"; } }; diff --git a/src/data/roadmaps/cpp/content/112-idioms/106-copy-write.md b/src/data/roadmaps/cpp/content/112-idioms/106-copy-write.md index df24f912c..4c509ca77 100644 --- a/src/data/roadmaps/cpp/content/112-idioms/106-copy-write.md +++ b/src/data/roadmaps/cpp/content/112-idioms/106-copy-write.md @@ -14,7 +14,7 @@ public: // Use the same shared data for copying. MyString(const MyString &other) : data(other.data) { - std::cout << "Copied using the Copy-Write idiom." << std::endl; + std::cout << "Copied using the Copy-Write idiom.\n"; } // Make a copy only if we want to modify the data. @@ -22,7 +22,7 @@ public: // Check if there's more than one reference. if (data.use_count() > 1) { data = std::make_shared<std::string>(*data); - std::cout << "Copy is actually made for writing." << std::endl; + std::cout << "Copy is actually made for writing.\n"; } *data = str; } diff --git a/src/data/roadmaps/cpp/content/115-compilers/index.md b/src/data/roadmaps/cpp/content/115-compilers/index.md index fa6e5b4c9..8a9245980 100644 --- a/src/data/roadmaps/cpp/content/115-compilers/index.md +++ b/src/data/roadmaps/cpp/content/115-compilers/index.md @@ -22,7 +22,7 @@ Let's say you have a simple C++ program saved in a file called `hello.cpp`: #include <iostream> int main() { - std::cout << "Hello, World!" << std::endl; + std::cout << "Hello, World!\n"; return 0; } ``` diff --git a/src/data/roadmaps/cpp/content/libraries/100-boost.md b/src/data/roadmaps/cpp/content/libraries/100-boost.md index bd0d66fa4..fadd73b1d 100644 --- a/src/data/roadmaps/cpp/content/libraries/100-boost.md +++ b/src/data/roadmaps/cpp/content/libraries/100-boost.md @@ -27,15 +27,15 @@ int main() { boost::filesystem::path path("directory_path"); if (boost::filesystem::exists(path)) { - std::cout << "Path: " << path << " exists!" << std::endl; + std::cout << "Path: " << path << " exists!\n"; if (boost::filesystem::is_directory(path)) { - std::cout << "Path: " << path << " is a directory." << std::endl; + std::cout << "Path: " << path << " is a directory.\n"; } else if (boost::filesystem::is_regular_file(path)) { - std::cout << "Path: " << path << " is a regular file." << std::endl; + std::cout << "Path: " << path << " is a regular file.\n"; } } else { - std::cout << "Path: " << path << " does not exist!" << std::endl; + std::cout << "Path: " << path << " does not exist!\n"; } return 0; diff --git a/src/data/roadmaps/cpp/content/libraries/101-open-cv.md b/src/data/roadmaps/cpp/content/libraries/101-open-cv.md index e31bfa268..22ff4f380 100644 --- a/src/data/roadmaps/cpp/content/libraries/101-open-cv.md +++ b/src/data/roadmaps/cpp/content/libraries/101-open-cv.md @@ -20,7 +20,7 @@ Here's a simple example using OpenCV in C++ to read and display an image: int main(int argc, char** argv) { if (argc != 2) { - std::cout << "Usage: display_image ImageToLoadAndDisplay" << std::endl; + std::cout << "Usage: display_image ImageToLoadAndDisplay\n"; return -1; } @@ -28,7 +28,7 @@ int main(int argc, char** argv) { image = cv::imread(argv[1], cv::IMREAD_COLOR); if (!image.data) { - std::cout << "Could not open or find the image" << std::endl; + std::cout << "Could not open or find the image\n"; return -1; } diff --git a/src/data/roadmaps/cpp/content/libraries/104-grpc.md b/src/data/roadmaps/cpp/content/libraries/104-grpc.md index f31b5239c..531bde283 100644 --- a/src/data/roadmaps/cpp/content/libraries/104-grpc.md +++ b/src/data/roadmaps/cpp/content/libraries/104-grpc.md @@ -107,7 +107,7 @@ class GreeterClient { if (status.ok()) { return reply.message(); } else { - std::cout << "RPC failed" << std::endl; + std::cout << "RPC failed\n"; return "RPC failed"; } }