VS14 CTP – Create Declaration / Definition

The CTP 2 has a mostly stable implementation of the “Create Declaration / Definition” refactoring tool for your C++ projects. It lets you auto generate the definition or declaration of a member function. Example, if you have a class called Employee, declared in Employee.h and defined in Employee.cpp, you can type in a function declaration into the .h file and have the body auto-generated for you in the cpp file.

cdd02

You’ll get an empty definition.

int Employee::Foo(int x, int y, double d)
{
    return 0;
}

You can do the reverse too. Say you want to add an overload without the double paramater. Just copy paste this definition, remove the double paramater and then use the refactoring option.

cdd01

That’ll generate this for you.

int Foo(int x, int y);

Quite useful. That said, I wish it would do something like this. If I have code as follows.

Employee e;
e.Bar();

If you right click Bar() and choose this refactoring option, you’ll get a message that says – “The selected text does not contain any function signatures.”

Now that would have been handy. C# has had that for at least 2 iterations now.

Advertisements
Posted in C++

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s