R
R
Riddik2016-04-05 09:08:17
C++ / C#
Riddik, 2016-04-05 09:08:17

Is there a quick way to define methods in .cpp files?

Hello.
Maybe I missed something, but the process of writing code in C ++ is somewhat delayed when you first declare the methods in the .h/hpp file, then copy-paste it to the .cpp file, if the body of the method is 2-3 lines, sometimes this process takes longer than coding the method body itself.
Maybe I'm just not aware of how this can be automated?)
Example, you declare a class method in a .h-file:

//source.h
...
class Test
{
    void someFunc(float x = 0.f, float y = 0.f);
};

Then you "press the button" and see the following construction in the .cpp file
//source.cpp
#include "source.h"
...
void Test::someFunc(float x, float y)
{

}

Is there such a thing?) Without superfluous and cumbersome)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Silin, 2016-04-05
@TrueRiddik

Well, it depends on the IDE and the tools for it. QtCreator does this out of the box. It even monitors method signatures and suggests fixing them when something has changed. VS 2015 can also do something like this, but I'm not sure, I haven't written in it for a long time on the pluses.

G
GavriKos, 2016-04-05
@GavriKos

There is. Use resharper c++ or VisualAssist.

I
iv_k, 2016-04-05
@iv_k

the body of the method can be described directly in the .h file. but not recommended

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question