c++学习笔记4:如何写好注释
1.单行注释一般放在语句的上方:
// cout and endl live in the iostream library
std::cout << "Hello world!" << std::endl;
2.多行注释写法:
/* This is a multi-line comment.
* the matching asterisks to the left
* can make this easier to read
*/
3.注释的用处
.At the library, program, or function level, describe what
.Inside the library, program, or function, describe how
.At the statement level, describe why
通俗点就是:
(1)描述该块代码是什么;
(2)描述该块代码如何实现;
(3)描述该块代码为什么要如此实现;
接下来举些例子:
(1)what
// This program calculate the student's final grade based on his test and homework scores.
(2)how
/* To calculate the final grade, we sum all the weighted midterm and homework scores
and then divide by the number of scores to assign a percentage. This percentage is
used to calculate a letter grade.
*/
// To generate a random item, we're going to do the following:
// 1) Put all of the items of the desired rarity on a list
// 2) Calculate a probability for each item based on level and weight factor
// 3) Choose a random number
// 4) Figure out which item that
(3)why
// We need to divide items by 2 here because they are bought in pairs
cost = items / * storePrice;
c++学习笔记4:如何写好注释的更多相关文章
- java之jvm学习笔记五(实践写自己的类装载器)
java之jvm学习笔记五(实践写自己的类装载器) 课程源码:http://download.csdn.net/detail/yfqnihao/4866501 前面第三和第四节我们一直在强调一句话,类 ...
- iOS学习笔记-自己动手写RESideMenu
代码地址如下:http://www.demodashi.com/demo/11683.html 很多app都实现了类似RESideMenu的效果,RESideMenu是Github上面一个stars数 ...
- java之jvm学习笔记六(实践写自己的安全管理器)
安全管理器SecurityManager里设计的内容实在是非常的庞大,它的核心方法就是checkPerssiom这个方法里又调用AccessController的checkPerssiom方法,访问控 ...
- CSS学习笔记六:写原生导航栏
因为刚开始学习CSS时,只了解了一些基本样式,然后就跑去学习bootstrap.bootstrap是个不错的东西,挺好玩,起码让你写界面写的轻轻松松,几行引入代码,再来个复制粘贴就解决了,而且boot ...
- 【Java学习笔记】如何写一个简单的Web Service
本Guide利用Eclipse以及Ant建立一个简单的Web Service,以演示Web Service的基本开发过程: 1.系统条件: Eclipse Java EE IDE for Web De ...
- Python学习笔记 - 用VSCode写python的正确姿势
最近在学习python,之前一直用notepad++作为编辑器,偶然发现了VScode便被它的颜值吸引.用过之后发现它启动快速,插件丰富,下载安装后几乎不用怎么配置就可以直接使用,而且还支持markd ...
- python3学习笔记(三):注释和字符串
一.注释 为了让别人能够更容易理解程序,使用注释是非常有效的,即使是自己回头再看旧代码也是一样. # 打印圆的周长: print(2* pi* r) 在python 中用井号(#)表示注释.井号(#) ...
- python学习笔记(基础二:注释、用户输入、格式化输出)
注释 单行:# 多行:上下各用3个连续单引号或双引号 3个引号除了多行注释,还可以打印多行 举例: msg = ''' name = "Alex Li" name2 = name ...
- Java学习笔记(1):注释规范
注释规范 1. 类注释 在每个类前面必须加上类注释,注释模板如下: 2. 属性注释 在每个属性前面必须加上属性注释,注释模板如下: 3. 方法注释 在每个方法前面必须加上方法注释,注释模板 ...
- PHP学习笔记,自己动手写个MVC的框架
最新在大家自己的博客的过程中,发现各种开源的博客系统都或多或少的用起来别扭.于是想动手自己写个博客系统.既然写,就想好好写.那就先写个MVC框架.一点一点来.写的过程中有很多想法.还希望大家能够多多指 ...
随机推荐
- SecureCRT中的ftp文件上传
原文地址:http://www.blogbus.com/jjuan-flake-logs/59745331.html SecureCRT与SshClient不同的就是,SecureCRT没有图形化的文 ...
- 通过class和id获取DOM元素的区别
1.通过id获取DOM元素的方法:document.getElementById("id名") 2.通过class获取DOM元素的方法:document.getElementsBy ...
- 碰到sshd连接不上linux时的解决办法
1,首先更改ssh配置,可以是ssh端口连接不上服务器 cd /etc/ssh/sshd_config vi !$ Port 52113 //ssh默认的连接端口, 改为别人不知道的端口 Permit ...
- 计算excel列的名字
#include <iostream> using namespace std; int main() { unsigned int column; cin>> ...
- Android——关于Activity跳转的返回(无返回值和有返回值)——有返回值
说明: 跳转页面,并将第一页的Edittext输入的数据通过按钮Button传到第二页用Edittext显示,点击第二页的 返回按钮Button返回第一页(改变第二页的Edittext的内容会传至第一 ...
- POJ 1050 To the Max 暴力,基础知识 难度:0
http://poj.org/problem?id=1050 设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和 首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x ...
- PowerMock遇到的问题——4
当我们在测试一个方法的构造方法的时候,有的时候内部需要new一些对象,这是就需要用到PowerMock.exceptNew(),这个方法,但有时候传的参数有关键字this,比如SAPPublisher ...
- C# 正则表达式 验证:数字、带小数点数字、电话和手机
一.带小数点数字 public static bool IsNumber(string input) { string pattern = "^-?\\d+$|^(-?\\d+)(\\.\\ ...
- win10系统的点评
Windows 10 是美国微软公司所研发的新一代跨平台及设备应用的操作系统.在正式版本发布一年内,所有符合条件的Windows7.Windows 8.1的用户都将可以免费升级到Windows 10, ...
- 弹框工作区(dialog)
弹出窗口分为普通弹出窗口和模态弹出窗口,普通弹出窗口可以铜鼓taskBar组件进行最小化等操作.弹出的窗口的DOM结构会放入主页面的body中,结构如下: <div class="bj ...