> For the complete documentation index, see [llms.txt](https://42-guide.gitbook.io/42-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://42-guide.gitbook.io/42-guide/core-curriculum/rank04/module00.md).

# Module00

Welcome to **C++ Module 00**! This module is designed to introduce you to the fundamentals of **Object-Oriented Programming (OOP)** using C++. By the end of this module, you will have a solid understanding of basic C++ concepts, including **namespaces, classes, member functions, initialization lists, static and const members, and standard input/output streams**. You will also get hands-on experience with writing C++ programs that adhere to the **C++98 standard**.

This module is your first step into the world of C++, and it builds on your existing knowledge of C programming. While C++ is a powerful and complex language, this module will guide you through the basics in a structured and progressive manner. The exercises will increase in complexity, helping you to gradually build your skills and confidence in C++ programming.

***

#### **What You Will Learn**

By completing the exercises in this module, you will gain the following knowledge and skills:

1. **Namespaces**:
   * Understand the concept of namespaces and how they help avoid naming conflicts.
   * Learn how to define and use namespaces in your programs.
2. **Classes and Objects**:
   * Learn how to define classes and create objects.
   * Understand the difference between **public** and **private** members of a class.
   * Implement **member functions** to define the behavior of your classes.
3. **Member Functions**:
   * Write member functions to manipulate the data members of a class.
   * Understand the concept of **encapsulation** and how it helps in designing robust classes.
4. **Initialization Lists**:
   * Learn how to use initialization lists to initialize class members efficiently.
   * Understand why initialization lists are preferred over assignment in constructors.
5. **Static and Const Members**:
   * Understand the use of **static** members in classes.
   * Learn how to use **const** members and functions to enforce immutability.
6. **Standard Input/Output Streams**:
   * Use C++ standard input/output streams (`std::cin`, `std::cout`) for reading and writing data.
   * Understand the difference between C-style `printf`/`scanf` and C++ streams.
7. **Basic C++ Syntax and Conventions**:
   * Follow C++ naming conventions (e.g., `UpperCamelCase` for class names).
   * Write clean, readable, and maintainable C++ code.
8. **Memory Management**:
   * Understand the basics of memory management in C++.
   * Learn how to avoid memory leaks when using dynamic memory allocation (`new` and `delete`).
9. **Orthodox Canonical Form**:
   * Learn about the **Orthodox Canonical Form** for class design, which includes:
     * Default constructor
     * Copy constructor
     * Copy assignment operator
     * Destructor
10. **Standard Library Usage**:
    * Use the C++ Standard Library effectively (with restrictions in earlier modules).
    * Avoid using forbidden functions like `*printf()`, `*alloc()`, and `free()`.

***

#### **What You Need to Know After Completing This Module**

After finishing all the exercises in this module, you should be able to:

1. **Write Basic C++ Programs**:
   * Write programs that use classes, objects, and member functions.
   * Use namespaces to organize your code and avoid naming conflicts.
2. **Design and Implement Classes**:
   * Design classes that encapsulate data and behavior.
   * Use initialization lists, static members, and const members effectively.
3. **Handle Input and Output**:
   * Use C++ streams for input and output operations.
   * Format output using manipulators like `std::setw`, `std::setfill`, etc.
4. **Follow C++ Best Practices**:
   * Write code that adheres to C++98 standards.
   * Avoid common pitfalls like memory leaks and undefined behavior.
5. **Understand the Basics of OOP**:
   * Grasp the core concepts of OOP, including encapsulation, abstraction, and modularity.
   * Apply these concepts to solve real-world problems using C++.
6. **Prepare for Advanced Topics**:
   * Build a strong foundation for more advanced C++ topics, such as inheritance, polymorphism, and templates (covered in later modules).

***

#### **How to Approach the Exercises**

The exercises in this module are designed to be progressive, meaning each exercise builds on the knowledge gained from the previous one. Here’s how you should approach them:

1. **Read the Instructions Carefully**:
   * Each exercise comes with specific instructions and requirements. Make sure you understand them before starting.
2. **Plan Your Solution**:
   * Break down the problem into smaller parts and plan how you will implement each part.
   * Think about the classes, member functions, and data structures you will need.
3. **Write Clean and Readable Code**:
   * Follow the naming conventions and formatting guidelines provided.
   * Write code that is easy to understand and maintain.
4. **Test Your Code**:
   * Test your program with different inputs to ensure it behaves as expected.
   * Check for edge cases and handle them appropriately.
5. **Refactor and Improve**:
   * Once your code works, look for ways to improve it (e.g., by using initialization lists or const members).

***

#### **Exercises Overview**

Here’s a brief overview of the exercises you will complete in this module:

1. **Exercise 00: Megaphone**:
   * Write a program that takes input from the command line and outputs it in uppercase.
   * Learn how to handle command-line arguments and use loops and conditionals.
2. **Exercise 01: My Awesome PhoneBook**:
   * Implement a simple phonebook application using two classes: `PhoneBook` and `Contact`.
   * Learn how to manage an array of objects and handle user input.
3. **Exercise 02: The Job Of Your Dreams**:
   * Recreate a missing C++ file (`Account.cpp`) based on a given header file (`Account.hpp`) and a log file.
   * Learn how to work with static members and understand the order of constructor and destructor calls.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-guide.gitbook.io/42-guide/core-curriculum/rank04/module00.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
