什么网站能接单做网站,如何做网站左侧导航条,公司网站开发题目来源,南安网站建设我们来看上节所写的程序
#include iostream
using namespace std;void prnt() //打印A
{cout printA endl;
}int main()
{prnt();return 0;
}
上面的程序中“//打印A”#xff0c;表示说明当前函数是打印内容的函数#xff0c;具体…我们来看上节所写的程序
#include iostream
using namespace std;void prnt() //打印A
{cout printA endl;
}int main()
{prnt();return 0;
}
上面的程序中“//打印A”表示说明当前函数是打印内容的函数具体打印结果写了一个A没有再进行更详细的描述这个时候我们看到的时候能大概了解一下这个函数是做什么的但是还得要执行函数才能知道结果那么 ”//“后面的内容就是注释。
在编程时注释是一个非常实用的一个工具或者是功能可以极大提高代码的可读性和可维护性上面的函数比较简单可能看一眼就知道是什么意思但是如果写一个功能复杂的函数或者是比较大的函数看一下下面的函数非C代码实际工作时写的方法 public TmsDistributionLineVo autoDistributionLine(String accessId, BasePickUpPoint point, String orderChannel) {try {/*** 获取距离最近的点*/MPJQueryWrapperTmsDistributionLine mpjQW null;/*** 获取距离最近的线*/mpjQW new MPJQueryWrapperTmsDistributionLine();String sql StrUtil.format( st_distance_sphere(point({},{}), point(lng_center,lat_center)) distance ,point.getLongitude(), point.getLatitude());mpjQW.select( id,distribution_line_name, sql);mpjQW.lambda().eq(TmsDistributionLine::getLogisticsAreaId, point.getLogisticsAreaId());mpjQW.eq(access_id, accessId);mpjQW.eq(is_del, 0);mpjQW.eq(flag, 1);mpjQW.lambda().eq(TmsDistributionLine::getOrderChannel, orderChannel);mpjQW.orderByAsc(distance);mpjQW.last( limit 1);TmsDistributionLineVo line this.selectJoinOne(TmsDistributionLineVo.class, mpjQW);if (line ! null line.getDistance().doubleValue() 1000) { } else {mpjQW new MPJQueryWrapperTmsDistributionLine();sql StrUtil.format( st_distance_sphere(point({},{}), point(longitude,latitude)) distance ,point.getLongitude(), point.getLatitude());mpjQW.innerJoin( tms_distribution_line_delivery_point_ref b on t.id b.distribution_line_id );mpjQW.innerJoin( base_pick_up_point c on c.id b.delivery_point_id );mpjQW.select(t.id, t.distribution_line_name, sql);mpjQW.lambda().eq(TmsDistributionLine::getLogisticsAreaId, point.getLogisticsAreaId());mpjQW.lambda().eq(TmsDistributionLine::getAccessId, accessId).eq(TmsDistributionLine::getIsDel, 0).eq(TmsDistributionLine::getFlag, 1);mpjQW.lambda().eq(TmsDistributionLine::getOrderChannel, orderChannel);mpjQW.orderByAsc(distance);mpjQW.last( limit 1);TmsDistributionLineVo vo this.selectJoinOne(TmsDistributionLineVo.class, mpjQW);//if (line null vo ! null)line vo;else {if (vo ! null vo.getDistance().doubleValue() line.getDistance().doubleValue()) //{line vo;}}}distributionLineDeliveryPointRefService.autoSaveRef(point.getLogisticsAreaId(), line.getId(), point.getId(), accessId, orderChannel);return line;} catch (Exception ex) {log.error(ex.getMessage());return null;} 我们写的时候可以感觉此代码挺简单功能也想很清楚但是等过一段时间再返回来看此代码就有点摸不着头脑了得需要一点点去分析去执行调试才能知道是什么意思。而且如果让其它人看此代码可能更不清楚代码是什么意思需要给其它人解析哪一段是什么意思执行之后将产生什么结果等等。不利用程序的维护可读性差。
在C代码中的注释语法有两种单行注释//和多行注释(/*....*/)。在编译的时候编译器会自动忽略注释的内容。
单行注释//)
单行注释用于注释一行代码比如对某一个变量的说明如上面的
void prnt() //打印A
//打印A就是单行注释。
多行注释主要用于注释整个代码块在注释中可以写明当前注释的内容或者是介绍当前函数的意义实现方式返回数据的类型等也可以注释掉整个代码块。
#include iostream
using namespace std;/*** 主要用于实现打印功能打印的内容为printA * * author 码农豆豆* version v1.0 * * return 无返回* * **/
void prnt()
{cout printA endl;
}int main()
{prnt();return 0;
}
上面的注释就是典型的多行注释用于解释当前函数的功能作者当前函数的版本号等等。
使用单行注释也可以完成只是写起来比较累而且很多不明确不如多行注释规范和明确如果当前函数暂时不需要也可以注释掉
#include iostream
using namespace std;/*** 主要用于实现打印功能打印的内容为printA * * author 码农豆豆* version v1.0 * * return 无返回* * **//* 暂时不需要注释掉
void prnt()
{cout printA endl;
}
*/int main()
{//prnt();return 0;
}
函数注释后在main中的引用也得注释了否则就会找不到这个函数提示没有定义。在main中使用了单行注释。
所以在程序中写注释是一个很重要的事情如果不写注释将大大降低程序的可性读和易维护性。因此一定要养成顺手写注释的习惯