This may be a minor question, but a solution would save me a lot of time and prevent mistakes.
I am working on a C++ project in Visual Studio. If I define a function in a class in a header file, say
void InitButton(int ButtonNum);
I usually copy and paste the signature to the cpp file. Then, I insert the class name, and replace the semi-colon with curly braces, like so:
void Button::InitButton() {
}
However, I'll often forget the class name, or accidentally type it before the return type. This also happens for any static variables I need to define in code. This seems small, but piles up since I'm at the beginning phase of a project. Is there a quicker way to auto-generate these in Visual Studio C++? Or a best practice I'm missing out on?
EDIT: It appears this has been asked before: Auto-create implementation in Visual Studio C++ 2010
EDIT 2: The best solution for me appears here: http://www.radwin.org/michael/2011/05/10/stubgen/
In Visual Studio 2015 there's the "Quick Actions" feature, a light bulb that shows up whenever you hover over a piece of code. In a header file one of the options is "Create definition of ... in ....cpp". This option generates the function definition in the corresponding header file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With