VS14 CTP – Move Definition Location

The CTP adds a refactoring option to move a function definition from header to cpp, or vice-versa. Just right-click on the definition, choose Refactor/Move Definition Location and that’s it.

// h file
class Employee
{
public:
  Employee();

  int Foo(int x, int y);
};

// cpp file
Employee::Employee()
{
}

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

mdl01

Now your code looks like this.

class Employee
{
public:
  Employee();

  int Foo(int x, int y)
  {
    return 0;
  }
};

You can do the reverse too. There seems to be a bug in this CTP though – when you move from the h to the cpp, it does not prefix the class-name, so you get this.

int Foo(int x, int y)
{
  return 0;
}

I would assume that this would be fixed in the RTM.

Seemingly a minor feature, but it is convenient and once you get used to it, you’ll start to miss it when you don’t have it (when using an older version or a different IDE).

Advertisement
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 )

Facebook photo

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

Connecting to %s