问题描述
我想使标头 .h
中的功能顺序与源文件 .cpp $ c中的功能顺序一致$ c>。
I want to make order of functions in header .h
to be consistent with the order of functions in source file .cpp
.
Bh
class B{
void f2(); //<--- wrong order
void f1();
};
B.cpp
#include "B.h"
void B::f1(){}
void B::f2(){}
预期结果(Bh)
class B{
void f1(); //<---- nice
void f2();
};
问题
主要问题:在Visual Studio中是否有任何(半)自动方式( .cpp-> .h
)?
热键?脚本?插入? Visual AssistX / Resharper?
Question
Primary Question: Is there any (semi) automatic way to do (.cpp -> .h
) in Visual Studio?
Hotkey? Script? Plugin? Visual AssistX / Resharper?
有,但它提出了相反的方式(没有解决方案)。
次要问题:如何自动执行相反的方式(半)? ( .h-> .cpp
)
There is a similar question but it asks the opposite way (it has no solution).
Secondary question: How to do the opposite way (semi) automatically? (.h -> .cpp
)
这是一个基本功能。它应该存在,对吧?
否则,专家该怎么做?他们是否手动移动它?
It is a basic feature. It should exist, right?
Otherwise, how would experts do about the disorder? Do they move it manually?
编辑:
所有三个答案都表明没有这种自动方式,但我仍然希望有。
All of the three answer states that there are no such automatic ways, but I still hope there are.
推荐答案
这只是我的意见!
由于以下原因,无法提供此类功能:
There can't be such functionality because of following reasons:
-
排序* .h文件导致混合了公共方法,受保护方法和私有方法,最好是将这些部分分开,然后您会立即看到组方法属于哪个方法。
Sorting *.h file cause mixing public, protected and private methods, better is to have these section separated then you see immediately in which group method belongs to.
您应该告诉您要排序的* .h文件,因为在一个* .cpp中,您可以具有多个类的定义,这些定义在多个* .h文件中声明。
You should tell which *.h file you want to sort, because in one *.cpp you can have definitions of multiple classes which are declared in multiple *.h files.
您应该告诉您要排序的* .h文件,因为* .cpp文件可以具有不同的名称trom * .h
You should tell which *.h file you want to sort, because *.cpp file can have different name trom *.h
这篇关于Visual Studio:热键/自动对.h中的函数进行排序以使其与.cpp保持一致的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!