相关疑难解决方法(0)

函数声明是否应包含参数名称?

您实际上会考虑更好的编码风格:在标题内声明函数/方法的参数名称,或仅在源文件中声明参数名称,因为可以同时执行这两种操作:如果您实际上只考虑在源文件中声明函数/方法的参数名称,那么您将如何声明默认值?

外标题:

//One.hpp
#ifndef ONE_HPP
#define ONE_HPP
namespace eins {

/** \brief description
 *  
 * \param one represents ....
 * \param two represents ....
 */
void function(int,int);

}
#endif

// One.cpp
#include "One.hpp"

eins::function(int one,int two) {
  //Do stuff//
}
Run Code Online (Sandbox Code Playgroud)

内部标题:

//One.hpp
#ifndef ONE_HPP
#define ONE_HPP
namespace eins {

/** \brief description
 *  
 * \param one represents ....
 * \param two represents ....
 */
void function(int one,int two);

}
#endif

// One.cpp
#include "One.hpp"

eins::function(int one,int two) {
  //Do stuff// …
Run Code Online (Sandbox Code Playgroud)

c++ coding-style

22
推荐指数
3
解决办法
1万
查看次数

标签 统计

c++ ×1

coding-style ×1