code-cleanup

How to call a function by its name (std::string) in C++?

北城以北 提交于 2019-11-26 12:03:29
问题 I wonder if there is a simple way to call a function from a string. I know a simple way, using \'if\' and \'else\'. int function_1(int i, int j) { return i*j; } int function_2(int i, int j) { return i/j; } ... ... ... int function_N(int i, int j) { return i+j; } int main(int argc, char* argv[]) { int i = 4, j = 2; string function = \"function_2\"; cout << callFunction(i, j, function) << endl; return 0; } This is the basic approach int callFunction(int i, int j, string function) { if(function

Order of items in classes: Fields, Properties, Constructors, Methods

谁都会走 提交于 2019-11-26 02:59:15
问题 Is there an official C# guideline for the order of items in terms of class structure? Does it go: Public Fields Private Fields Properties Constructors Methods ? I\'m curious if there is a hard and fast rule about the order of items? I\'m kind of all over the place. I want to stick with a particular standard so I can do it everywhere. The real problem is my more complex properties end up looking a lot like methods and they feel out of place at the top before the constructor. Any tips

How to identify unused css definitions [closed]

一曲冷凌霜 提交于 2019-11-25 23:39:20
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Are there any good approaches to help identify unused css definitions in a project? A bunch of css files were pulled in and now I\'m