我正在阅读Sedgewick的Algorithms 4th.第165页有消费税
编写一个方法
remove(),将链表和字符串键作为参数,并删除列表中具有键作为其项字段的所有节点.
我认为链表参数是多余的,因为实例方法始终使用对象名称进行调用.那么为什么作者希望它作为一个参数传递?(我不认为将remove()写为静态方法比实例方法更好.)
我知道参考不是点.引用不是对象.所以没有const引用.
const int ci = 1024;
const int &rl = ci;
Run Code Online (Sandbox Code Playgroud)
我们不能写int const &rl = ...但是今天,我学习二叉树源代码:
template <typename T> //take e as the node insert the left child of the tree.
BinNodePosi(T) BinNode<T>::insertAsLC(T const & e) { return lChild = new BinNode(e, this); }
Run Code Online (Sandbox Code Playgroud)
我对它的参数感到困惑:T const&e.为什么不是const T&e?我认为后者是对的..也许我的问题太简单了,不能在这里发布.与数学不同,研究水平和学习水平分别有两个方面:MathOverFlow和math.stackexchange ..我找不到stackoverflow的初级网站..所以我在这里发布.请原谅我.非常感谢.
我是MFC编程的新手.这些天我使用Jeff Prosise的书来学习MFC编程.我遇到过:CClientDC dc (this);我从CClientDC类的定义中找到了一个构造函数:CClientDC(CWnd* pWnd);但是如果我替换CClientDC dc (this);为CClientDC dc = CClientDC(this);.编译告诉我这是一个错误.我无法理解.我认为CClientDC dc (this);是一样的CClientDC dc = CClientDC(this);.或者换句话说,前者是一种简单的形式.
非常感谢.