A comprehensive collection of C++ coding problems, solutions, and resources to help you prepare for software engineering interviews. Ace your C++ interview with confidence!
To create a new question for the cracking-cpp
collection, follow these steps:
-
Create a folder for the question:
- Name the folder appropriately, using a descriptive and concise title for the question.
- Place the folder in the appropriate location within the project structure.
-
Create a CMake file for the question:
- Name the CMake file according to the question's folder name.
- Include any necessary build instructions or dependencies in the CMake file.
-
Add the question folder to the main CMake file:
- Open the main CMake file located in the root directory of the project.
- Add a reference to the question's folder in the appropriate section of the CMake file.
By following these steps, you can easily create a new question and integrate it into the cracking-cpp
project.
To build and run the questions in the cracking-cpp
collection, follow these steps:
-
Create a build directory:
- Open a terminal and navigate to the root directory of the project.
- Execute the following commands:
mkdir build
cd build
-
Generate the build files using CMake:
- Execute the following command:
cmake ..
- Execute the following command:
-
Build the project using the generated build files:
- Execute the following command:
make
(to build all questions) ormake sample_question
(to build a specific question)
- Execute the following command:
-
Run the executable:
- Execute the following command:
./sample_question/sample_question
(replacesample_question
with the appropriate question name)
- Execute the following command:
By following these steps, you can successfully build and run the questions in the cracking-cpp
project.
To simplify the process of building, testing, and cleaning the questions in the cracking-cpp
collection, a script called build.sh
is provided. Here is how you can use the script:
$ ./build.sh -h
The script supports the following options:
-h
: Print the help message.
You can use the script with the following commands:
build
: Build all questions.test
: Run tests for all questions.clean
: Clean build files.
Additionally, you can specify a question using the -q
option. By default, the script will perform the specified command for all questions. To specify a specific question, provide the name of the question after the -q
option.
By using the build.sh
script, you can easily build, test, and clean the questions in the cracking-cpp
project.