随笔分类 -  C++

摘要:事实上这个概念谁都有只是三种声明方式非常相似很容易记混。 Bjarne在他的The C++ Programming Language里面给出过一个助记的方法: 把一个声明从右向左读。 char * const cp; ( * 读成 pointer to ) cp is a const pointer to char const char * p; p is a pointer to const char; char const * p; 因为C++里面没有const*的运算符,所以const只能属于char const * p这句代码中(const)前面的(char)类型。即char con. 阅读全文
posted @ 2012-07-15 14:04 simplefrog 阅读(261) 评论(0) 推荐(0)
摘要:问:const char const * const GetName() const { return m_name; }; So, what is the explanation for each of these consts?答:Take them from the right. The one before the ; tells the client this is a design level const i.e. it does not alter the state of the object. (Think of this as a read-only method.)Ok. 阅读全文
posted @ 2012-07-15 14:03 simplefrog 阅读(315) 评论(0) 推荐(0)
摘要:一. native C++方式1.打开“Visual Studio 2010 命令提示”窗口,方法是单击“开始”,指向“所有程序”、“Microsoft Visual Studio 2010”、“Visual Studio 工具”,然后单击“Visual Studio 2010 命令提示”。2.在命令提示符下,键入 notepad basic.cpp,并按 Enter3.在记事本中,键入下列各行。#include <iostream>int main(){ std::cout << "This is a native C++ program." &l 阅读全文
posted @ 2012-07-11 18:53 simplefrog 阅读(772) 评论(0) 推荐(0)