I am using Visual Studio 2008, and I was wondering if it was possible to create the .cpp files given the header files.
So if I have a .h files with a class and functions, it can create the code file with all the functions typed in with a blank body
To create a header file for a new class, right-click to open the shortcut menu for the MathLibrary project in Solution Explorer, and then choose Add > New Item. In the Add New Item dialog box, select Visual C++ > Code. In the center pane, select Header File (. h).
. h files, or header files, are used to list the publicly accessible instance variables and methods in the class declaration. .cpp files, or implementation files, are used to actually implement those methods and use those instance variables.
Cpp files don't always have to have a header file associated with it but it usually does as the header file acts like a bridge between cpp files so each cpp file can use code from another cpp file. One thing that should be strongly enforced is the no use of code within a header file!
Shortcut: alt+shift+f10
(VS2015)
I've looked for this for over 10+ years, been told numerous times that nothing like this exists, and that one needs to somehow use external tools to get this basic functionality.
... Now, I've finally found something useful.
Highlight the class name in you .h file, and using that shortcut will make intellisense generate the relevant definitions (also creating the .cpp file if not created).
It's also a general purpose shortcut that ex. creates method stubs for you, if you create function signatures in the header (and highlight the function name). As you can see from the screenshot below, it also allows you to auto create all virtuals from the parent class, etc.
I absolutely cannot believe how much this has suddenly improved productivity (goodbye manual copy paste!). And I find it utterly shocking how I have never seen / been given reference to this, even in Stack Overflow, up until this point.
Enjoy your new powers, and spread the word!
You should check the Visual Assist X add-in for Visual Studio. It has lots of features.
You can say Project -> Add Class but that only does the basics. I don't think you can do (yet) what you are suggesting but it would be really awesome and there is no reason (that I can think of) why you cannot.
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