Tool for automatic header separation and C ++ implementation

I always feel pain when I switch from C # or python to C ++ and meet the separation of .h and .cpp.

So, I thought that perhaps there is a tool that, at the stage of preliminary compilation, can take the header (o file with some special extension) and split it into .h and .cpp?

So, if the source file looks like this:

class MyClass { public: void HaHaHa() { //some logic } } 

And the result will be like .h and .cpp files:

 //.h class MyClass { public: void HaHaHa(); } // .cpp #include "MyClass.h" void MyClass::HaHaHa() { //some logic } 

Some search engines did not have any ready-to-use tools. But I'm sure this is not a new idea, and such tools should exist.

PS It is known that, for example, Visual Assist X and VIM have tools for handling .h and .cpp separation with less pain. But I'm asking about the possibility of having code in one file and automatically separating it as part of the build process.

+6
source share
3 answers

This tool can help you: http://www.lazycplusplus.com/

+4
source

I think you go back about this: you want to write the header of the file, without implementation, before writing the code. To be good, this is a tool that will read the header file and generate implementation code for implementation: with namespaces, nested classes, and such, only wrappers can be quite verbose. But the closest thing I've seen is Rational Rose, which starts with a (very) annotated ULM diagram, and generates both a title and an implementation template. This is a very good tool, I use it whenever it is available. it's a little expensive for a home user and maybe even for a small corporation.

+2
source

In Windows, Visual Assist X does this thing all over Tomato. Not automated, although I do not think so.

0
source

Source: https://habr.com/ru/post/908423/


All Articles