Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast way to generate code functions from header functions in Visual Studio? [duplicate]

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/

like image 202
escapecharacter Avatar asked Jul 31 '13 04:07

escapecharacter


1 Answers

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.

like image 194
mrbraitwistle Avatar answered Sep 19 '22 03:09

mrbraitwistle