5

Common background goes first. In C++, you can write a method definition right inside the class body, as illustrated in the following Effective-C++ styled Widget class:

class Widget {
  unsigned TheSize;
public:
  unsigned getSize() const { return TheSize; }
};

I know this fashion is also called in-the-class definition and it is inline implicitly (without telling the compiler with keyword). On the other hand, you can write the method out of the class, explicitly qualifying its name, like:

class Widget {
  unsigned TheSize;
public:
  unsigned getSize() const;
};

unsigned Widget::getSize() const {
  return TheSize;
}

Now comes the question. I want to transform some classes written in the in-the-class fashion to the out-of-class fashion, using CLion, the new IDE made by JetBrains for C/C++. I wonder whether this nice-looking IDE provides builtin support for this refactoring. I can't see it has a refactoring called Pull Inline Method Out of Class though it does have the opposite Inline Method refactoring tool.

Edit: The CLion version I am using:

CLion 2018.3.1
Build #CL-183.4588.63, built on December 4, 2018
Licensed to CLion Evaluator
Expiration date: January 10, 2019
JRE: 1.8.0_152-release-1343-b16 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-42-generic
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
cgsdfc
  • 538
  • 4
  • 19
  • 14
    Hi @cgsdfc. Now sure about the whole class, but if you put the cursor on some class method and press `alt+enter` you can call `Split function into declaration and definition` action – Maxim Banaev Dec 20 '18 at 09:06
  • @MaximBanaev Nice shot! That's exactly what I am looking for! It works pretty well. – cgsdfc Dec 20 '18 at 16:09
  • Very nice @MaximBanaev! You should make this an answer! – andreee Mar 07 '19 at 12:48

0 Answers0