---
title: "C++ | CoderPad"
description: "Learn more about C++ from CoderPad."
canonical: "https://coderpad.io/languages/cpp/"
last_modified: "2023-04-17 03:49:41"
---
# C++ online IDE & code editor for technical interviews

Running GCC 9.4 (C++20) – IntelliSense is enabled

### Experience the C++ IDE yourself

See just how easy and intuitive CoderPad Interview is to use below.

[Launch the environment](https://embed.coderpad.io/sandbox?question_id=247192&use_question_button)

## Guidelines to use C++ in this online IDE

We run your C++ code with GCC 8. You should define an`int main()`entrypoint. The gcc compiler is invoked with the following args:

```
g++ -Wall -fsanitize=address -std=c++17 -pthread \
-lboost_date_time -lboost_regex -lboost_system -lboost_thread -lboost_timer -lboost_filesystem \
-lssl -lcrypto -lmysqlcppconn

```

Which results in:

- Use the C++17 standard
- Turn on all warning messages
- Compile in debug mode
- Warn on memory use-after-free bugs and other memory issues with [ASan](https://github.com/google/sanitizers/wiki/AddressSanitizer). If you see an unusual message or segfault, it’s likely ASan picking up a use-after-free or use of uninitialized memory bug in your code.
- Link the`pthread`library
- Link a few static boost libraries

We also provide a few libraries:

- [Boost](https://www.boost.org/) is provided, with most of its header-only libraries working straight out of the box. Of its statically compiled components, we link to`DateTime`,`Regex`,`System`,`Thread`, and`Timer`. If you need more than those, please let us know!
- [nlohmann/json](https://github.com/nlohmann/json), a convenient and simple JSON library. To use it on CoderPad, just include`"json.hpp"`and go nuts:

```
  #include "json.hpp"
  #include <iostream>

  int main() {
    nlohmann::json j2 = {
      {"hello", "world"}
    };
    std::cout << j2;
  }

Code language: CSS (css)
```
- [Catch](https://github.com/philsquared/Catch), a C++ testing library. Catch is a single-header library and very easy to get started with. To use it on CoderPad, simply define a macro and include the header like so:

```
  #define CATCH_CONFIG_MAIN
  #include "catch.hpp"

  unsigned int Factorial( unsigned int number ) {
      return number <= 1 ? 1 : Factorial(number - 1) * number;
  }

  TEST_CASE( "Factorials are computed", "[factorial]" ) {
      REQUIRE( Factorial(0) == 1 );
      REQUIRE( Factorial(1) == 1 );
      REQUIRE( Factorial(2) == 2 );
      REQUIRE( Factorial(3) == 6 );
      REQUIRE( Factorial(10) == 3628800 );
  }
Code language: C++ (cpp)
```

If you do so, you should NOT define your own main method. You can also read more about [Catch’s macros for testing](https://github.com/philsquared/Catch/blob/master/docs/tutorial.md#test-cases-and-sections).

- [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page), a library for linear algebra. We provide [all of the Eigen modules and header files](https://eigen.tuxfamily.org/dox/group__QuickRefPage.html#QuickRef_Headers) to the environment. To use it in CoderPad, just include the header that you want and instantiate an object:

```
  #include <iostream>
  #include <Eigen/Dense>

  using Eigen::MatrixXd;

  int main()
  {
    MatrixXd m(2,2);
    m(0,0) = 3;
    m(1,0) = 2.5;
    m(0,1) = -1;
    m(1,1) = m(1,0) + m(0,1);
    std::cout << m << std::endl;
  }Code language: C++ (cpp)
```

## Need a better way to interview candidates?

[Request a demo](https://coderpad.io/sales/)
