摘要: 解析(a (b c))+----+------+-------+|LIST|list=o|next=o--->NULL+----+-----|+-------+ | +-------+ | v+-----+-------+-------+ +----+------+-------+|VALUE|val="a"|next=o--->|LIST|list=o|next=o--->NULL+-----+-------+-------+ +----+-----|+-------+ | ... 阅读全文
posted @ 2012-07-18 21:02 propheteia 阅读(370) 评论(0) 推荐(0) 编辑
摘要: #ifndef __STATICMODULE_H#define __STATICMODULE_H#include <iostream>#include <cassert>template <class T>class StaticModule{protected: static T* s_instance;public: static void init() { if (s_instance) assert(0); s_instance=new T; } static T& getInstance(... 阅读全文
posted @ 2012-07-17 16:34 propheteia 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 1 非引用形参(复制实参的值给形参) 1)非引用形参表示对应实参的局部副本。这类形参的修改仅仅修改了局部副本的值。一旦函数执行结束,这些局部变量的值就没有了。 2)指针形参。操纵地址和地址的值。 3)const形参。如void fcn(const int i) 不可以改变实参的局部副本。 可以传递给fcn非const对象或者const对象。 什么时候不适合复制实参? 1)需要在函数中修改实参的值。 2)需要大型对象作为实参传递。这样复制对象付出的时间和存储空间代价太大。 怎样解决? 可将形参定义为引用或者指针类型。2 引用形参(它是实参的别名) 1)函数运行时,对实参... 阅读全文
posted @ 2012-07-17 13:58 propheteia 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1 多态性#include<iostream>class animal{ public: virtual void breath() { std::cout<<"animal breath"<<std::endl; }};class fish:public animal{ public: void breath() { std::cout<<"fish breath"<<std::endl; }};int main(){ ... 阅读全文
posted @ 2012-07-16 19:53 propheteia 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 字符串字面值,如acbd,和string类型不是同一种类型,因此无法比较。 #include<iostream>using namespace std;int main(){ string s; if(s.empty()) { s = "abcde"; cout<<s.size()<<endl; //返回size_type类型 输出为:5 cout<<s[3]<<endl;//返回字符串的第三个字符 输出为:c } cout<<sizeof(string::size_type)<... 阅读全文
posted @ 2012-07-13 11:47 propheteia 阅读(553) 评论(0) 推荐(0) 编辑
摘要: 存储器没有任何结构和意义让存储器具有结构的基本方法是块(chunk)处理存储.大部分计算机使用特定位数的块来处理存储,有8,16,32,64位。这里使用的是64位的机器。虽然确切的大小因机器不同而不同,但通常都将8位的块作为一个字节。4个字节作为一个word.每个字节都有它的地址。比如722323.要让722323这个地址有意义, 必须知道存储在该地址的值的类型。一旦知道了该地址值的类型,就知道了表示该类型的值需要多少位以及如何解释这些位。例如,地址722323的位,若是无符号整数类型,则表示113;若是字符类型,则表示q.下面是64位linux系统下常见数据类型的大小:#include< 阅读全文
posted @ 2012-07-12 21:53 propheteia 阅读(7284) 评论(0) 推荐(0) 编辑
摘要: stringstream是字符串流。它将流与存储在内存中的string对象绑定起来。在多种数据类型之间实现自动格式化。1 stringstream对象的使用#include<sstream>#include<iostream>using namespace std;int main(){ string line,word; while(getline(cin,line)) { stringstream stream(line); cout<<stream.str()<<endl; ... 阅读全文
posted @ 2012-07-12 15:41 propheteia 阅读(28853) 评论(1) 推荐(4) 编辑
摘要: BaseAgent *AgentAgent =new BaseAgent;new 返回新创建对象的指针。此处BaseAgent是一个类名。问题:new是否创建了对象?如果创建了对象是否通过构造函数创建?代码:class aaa{ public: aaa(int x, int y):a(x),b(y),c(0){} int c; int a; int b; private:};#include "head.h"#include <iostream>i... 阅读全文
posted @ 2012-07-08 16:09 propheteia 阅读(556) 评论(0) 推荐(0) 编辑
摘要: 1)不能被修改const bufsize = 512;buffsize在定义时必须初始化;定义处之外无法修改buffsize的值2)只能在定义它的文件中使用file_1.cpp extern const int bufsize =512; file_2.cpp extern const int bufsize; 通过指定const对象为extern,才能在其他文件中被访问。否则只能在file_1.cpp中被访问。3)指向const对象的指针 const double *cptr; // cptr为指向double型的const对象的指针 cptr可以改变,但是指向的类型不可以改变,为co... 阅读全文
posted @ 2012-06-27 20:49 propheteia 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 任务:1)替换文件夹 2)进入新文件夹,编译,连接 3)执行程序 4)运行脚本 1 #/bin/bash 2 path="Strive3d_2012_Chinaopen" 3 path_build="all_build" 4 path_buildone="one_build" 5 rm -rf ./$path/all_build 6 cp -r ./$path_build ./$path/$path_build 7 cd ./$path/$path_build 8 cmake .. 9 make10 make install11 rc 阅读全文
posted @ 2012-06-26 21:58 propheteia 阅读(668) 评论(0) 推荐(0) 编辑