Create template-based files
CLion provides file templates for most of the supported languages. These templates help you create files with initial content already present.
There are four templates for C/C++: C++ Class, C++ Source File, C++ Header File, and C++ Module Interface Unit.
Create a new C++ class
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
Specify the name of the new class.
Use the default file type or choose from the drop-down list:
Click the spanner icon to access the default file extensions settings:
In the Namespace field, set the namespace for your class.
If you specify a nonexistent namespace, it will be created along with the new class.
This field has basic validation checking for whether the identifier is a valid namespace name (or a blank space).
Select the Create header only checkbox if you want to create the header file only.
CLion can automatically add files to CMake targets.
Select the target from the list or click Add new target to create a new one. For more information, refer to Adding files to CMake projects.
Create a new C/C++ source file
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
Specify the name of the new file.
Use the default file type or choose from the drop-down list:
Click the spanner icon to access the default file extensions settings:
Select the Create an associated header checkbox to create the corresponding header file as well.
CLion can automatically add files to CMake targets.
Select the target from the list or click Add new target to create a new one. For more information, refer to Adding files to CMake projects.
Create a new C/C++ header
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
Specify the name of the new file.
Use the default file type or choose from the drop-down list:
Click the spanner icon to access the default file extensions settings:
CLion can automatically add files to CMake targets.
Select the target from the list or click Add new target to create a new one. For more information, refer to Adding files to CMake projects.