*.h or *.hpp for C++ header files: which extension to choose?
Hi everyone! I'm new to C++ and developing my first small project — a class for working with matrices. I noticed that different projects and textbooks use different extensions for header files: some write `matrix.h`, others `matrix.hpp`. I got confused.
I'm used to all header files in C having the `.h` extension. But C++ is a separate language, even though it's largely based on C. When I write a class definition, for example:
```cpp
// matrix.h
#ifndef MATRIX_H
#define MATRIX_H
class Matrix {
public:
Matrix(int rows, int cols);
void print() const;
private:
int rows_, cols_;
double* data_;
};
#endif
```
...it seems logical to me to use `.hpp` to explicitly indicate that this is C++, not C. But some colleagues say that `.h` is a
No answers yet.
Log in to leave an answer