- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题在这里已经有了答案:
12 年前关闭。
Possible Duplicates:
Formatting of if Statements
Is there a best coding style for identations (same line, next line)?
Best way to code stackoverflow style 'questions' / 'tags' rollover buttons
public void Method {
}
public void Method
{
}
最佳答案
Return type on the same line as function name, parameters on the same line if they fit.
Functions look like this:
ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {
DoSomething();
...
}
Function definitions: place each brace on its own line.
Right:
int main()
{
...
}Wrong:
int main() {
...
}
It is important to put the open-brace that starts the body of a C function in column one, so that they will start a defun. Several tools look for open-braces in column one to find the beginnings of C functions. These tools will not work on code not formatted that way.
Avoid putting open-brace, open-parenthesis or open-bracket in column one when they are inside a function, so that they won't start a defun. The open-brace that starts a struct body can go in column one if you find it useful to treat that definition as a defun.
It is also important for function definitions to start the name of the function in column one. This helps people to search for function definitions, and may also help certain tools recognize them. Thus, using Standard C syntax, the format is this:
static char *
concat (char *s1, char *s2)
{
...
}or, if you want to use traditional C syntax, format the definition like this:
static char *
concat (s1, s2) /* Name starts in column one here */
char *s1, *s2;
{ /* Open brace in column one here */
...
}
else
,不过只要大家在代码上能配合,真的无所谓。
关于curly-braces - 括号放置会影响可读性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/895326/
这个问题在这里已经有了答案: Why can't member initializers use parentheses? (2 个答案) 关闭 7 年前。 #include #include
我正在尝试使用宏以默认值初始化结构元素。不幸的是,我不断收到警告,但我无法找到其解决方案,任何人都可以帮助我了解我到底做错了什么吗? 注意: 我在初始化时收到警告。 我已经尝试了这两个宏,但仍然无法解
我遇到了以下结构: static struct { unsigned char a[5]; } b[] = { {1,1,1,1,1}, {2,2,
我有这个代码: #include int main(int, char **argv) { std::array a = {1,2,3}; } 这编译得很好 (-std=c++11) ,但如果
Npm 审计报告显示“发现 1 个低严重性漏洞”。 1 个漏洞需要人工审核。 Low Regular Expression Denial of Service Pack
template class Vec { T data[S]; public: constexpr Vec(const T& s) : data{s} {} }; templ
这个问题在这里已经有了答案: 12 年前关闭。 Possible Duplicates: Formatting of if Statements Is there a best coding styl
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
已更新我需要获取大括号 { } 之间的字符。 例如, a {v}" 输出:a,b 和 v 最佳答案 您可以使用 stingr 的 str_extract_all 在下面的表达式中(? a {v}{d}
我想知道是否使用 Belt and Braces (Suspenders)编程方法——尤其是数据验证——是否是好的做法。这来自以下示例。 我正在创建一个表单,并将监听器添加到所有字段中,这意味着 OK
在下面的代码中, struct X { int a; int b; void *ptr; }; class Base { public: int a; int b; void
我正在尝试做这样的事情..我有 3 个头文件 1. coordinates.h typedef struct { float x; float y; float z; }coordinat
是否可以在 C# 中退出作用域,例如可以 break 退出循环? private void a() { // do stuff here { // do more st
我正在学习 c#(和它的 OOP),我在 Visual Studio 中运行以下程序,它不断弹出一个错误,它需要一个花括号 } 我有写在这里。我想不通它为什么要那样。 using System; us
考虑以下两个带大括号的片段: switch (var) { case FOO: { x = x + 1; break; } case BAR: { y = y +
显示双花括号之间多个翻译的标签。 我在 Magento 2 的前端和后端都有这个问题。 这是我迄今为止尝试过的: 清除并刷新缓存 重新部署的静态内容 将 Magento 2.2.5 更新为 2.2.6
我看过这个问题 here . 我想知道是否存在以下缩进样式的官方名称: void fooBar(String s) { while (true) { // ... do
IE浏览器,这个: if (x > 5) return test; 总是会变成: if (x > 5) { return test; } 我不是在谈论大括号样式(Allman、GNU、Whit
这个问题已经有答案了: regular expression does not work with javascript (2 个回答) How do I replace all occurrence
scala coding standards说明 Technically, Scala’s parser does support GNU-style notation with opening br
我是一名优秀的程序员,十分优秀!