`
bliuqing
  • 浏览: 65249 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表

C++构造函数

    博客分类:
  • C++
class testint { public: testint(); testint(int b); //testint(testint& another); ~testint(); private: int i; }; //////////////// testint::testint() { cout<<"construct"<<endl; } testint::testint(int b):i(b) { cout<<"construct by " & ...
using namespace std; #include "stdafx.h" #include <iostream> void myswap(int A[], int i, int j){ int temp; temp = A[i]; A[i] = A[j]; A[j] = temp; } //插入 void inssort(int A[], int n){ for(int i = 1; i < n; i++) for(int j = i; j > 0; j--) { if(A[j] < ...

C移位

【转】 C提供了六种位运算运算符;这些运算符可能只允许整型操作数,即char、short、int和long,无论signed或者unsigned。 & 按位AND | 按位OR ^ 按位异或 << 左移 >> 右移 ~ 求反(一元运算) 按位与操作&通常用于掩去某些位,比如 n = n & 0177; 使得n中除了低7位的各位为0。 按位或操作|用于打开某些位: x = x | SET_ON; 使得x的某些SET_ON与相对的位变为1。 按位异或操作^使得当两个操作数的某位不一样时置该位为1,相同时置0。 应该区分位操作 ...
【转】http://www.programfan.com/blog/article.asp?id=30504 考虑下面问题:(默认对齐方式) union u {  double a;  int b; }; union u2 {  char a[13];  int b; }; union u3 {  char a[13];  char b; }; cout<<sizeof(u)<<endl; // 8 cout<<sizeof(u2)<<endl; // 16 cout<<size ...
【C++题库】http://www.xici.net/b694610/d44469284.htm 【C++题库】http://tieba.baidu.com/f?kz=558743069
Java深入到一定程度,就不可避免的碰到设计模式这一概念,了解设计模式,将使自己对java中的接口或抽象类应用有更深的理解.设计模式在java的中型系统中应用广泛,遵循一定的编程模式,才能使自己的代码便于理解,易于交流,Chain of Responsibility(职责链模式)模式便是其中一个.    Chain of Responsibility(CoR)职责链模式,CoR模式是用一系列类(classes)试图处理一个请求request,这些类之间是一个松散的耦合,唯一共同点是在他们之间传递request. 也就是说,来了一个请求,A类先处理,如果没有处理,就传递到B类处理,如果没有处理,就 ...
Chain of Responsibility定义 Chain of Responsibility(CoR) 是用一系列类(classes)试图处理一个请求request,这些类之间是一个松散的耦合,唯一共同点是在他们之间传递request. 也就是说,来了一个请求,A类先处理,如果没有处理,就传递到B类处理,如果没有处理,就传递到C类处理,就这样象一个链条(chain)一样传递下去。 如何使用? 虽然这一段是如何使用CoR,但是也是演示什么是CoR. 有一个Handler接口: public interface Handler{   public void handleRequest() ...
【转】http://www.iteye.com/topic/317132 装饰器涉及四个名词 1、接口或者抽象基类 2、被装饰对象,也就是一个简单的实现了1中提到的接口或者抽象基类的实现类。 3、装饰对象,就是去装饰被装饰对象的对象 4、继承装饰对象类的 ...

求100的阶乘

#include <stdio.h> int main() { int n; int a[9000]; //确保保存最终运算结果的数组足够大 int digit = 1; //位数 int temp; //阶乘的任一元素与临时结果的某位的乘积结果 int i,j,carry; //进位 printf("please in put n:\n"); scanf("%d",&n); a[0] = 1; //将结果先初始化为1 for(i = 2; i <= n; i++) { //开始阶乘,阶乘元素从2开始依次& ...
【策略模式应用场景举例】     比如在玩“极品飞车”这款游戏,那么游戏对车的轮胎是可以更换的,不同的轮胎在高速转弯时有不同的痕迹样式,那么针对“汽车”的配件“轮胎”就要可以变化,而且轮胎和轮胎之间是可以相互替换的,这就是典型的要应用“策略模式”的场景!从程序结构中可以看到,完全符合了前面我们的要求:“灵活”,“顺序敏感”。     【策略模式解释】     类型:行为模式     定义一组算法,将每个算法都封装起来,并且使它们之间可以互换。策略模式使这些算法在客户端调用它们的时候能够互不影响地变化。     【策略模式UML图】    【策略模式-JAVA代码实现】     从 ...
class Base{ { System.out.println("hello base"); } Base(){ System.out.println("Base"); } } class inner{ inner(){ System.out.println("inner"); } } public class constructtest extends Base{ inner in = new inner(); constructtest(){ //super(); ...
【转】http://blog.sina.com.cn/s/blog_4a5d4f74010009xf.html 首先: (1)构造函数不是方法,不能够继承;但是可以重载; (2)构造函数的执行阶段:     为子类和父类的所有域设默认值;     调用子类的构造函数;     调用父类的构造函数;(隐式或显式,显式的话一定要是第一个语句)     对父类域进行初始化;     执行父类构造函数的其余部分;     对子类域进行初始化;     执行子类构造函数体; (3)作为显式调用一部分的任何表达式都不允许引用当前对象的成员,     所有的域的初始化语句将按照顺序执行,在这时可以引用本队 ...

字符串操作

#include "stdafx.h" #include "stdio.h" #include <cstring> int main(int argc, char* argv[]) { //char d[] = "123"; char s[] = "123456789"; char d[] = "123"; strcpy(d,s); printf("%s,\n%s",d,s); printf("Hello World ...

C字符串反转

更改下面程序 #include string.h main(void) { char *src="hello,world"; char *dest=NULL; dest=(char *)malloc(strlen(src)); int len=strlen(str); char *d=dest; char *s=src[len]; whil ...

C链表相关

#include "stdafx.h" #include "stdio.h" #include "stdlib.h" typedef struct linknode{ int data; struct linknode *next; }node; node *create(){ node *head,*p,*s; int x, cycle=1; head = (node*)malloc(sizeof(node)); p = head; while(cycle){ printf(&q ...
Global site tag (gtag.js) - Google Analytics