摘要: 环境设置:安装完mysql vs中 vc++目录 中 包含目录 D:\DevSoft\MySQL\MySQL Server 5.5\include 这个文件夹vc++目录 中 引用目录 D:\DevSoft\MySQL\MySQL Server 5.5\lib 这个文件夹。 记得把 mysql 安装目录中的include目录下的libmysql.lib 复制到工程文件夹下。如果是32位的mysql 可以直接连。 如果是 64,需要 配置 vs x64平台,在配置管理其中,然后连。#include "stdafx.h" #include <Windows.h>#i 阅读全文
posted @ 2013-06-06 13:39 herizai 阅读(323) 评论(0) 推荐(0) 编辑
摘要: void mySort(int *b,int size);void f(){ int a[]={3,5,7,1,8,4,9}; mySort(a,sizeof(a)/sizeof(a[0]));//int *b=a}//数组是不能直接复制的//向量参数传递#include<iostream>#include<vector>#include<fstream>#include<sstream>using namespace std;typedef vector<int> VI;//typedeftypedef vector<VI&g 阅读全文
posted @ 2013-06-06 13:32 herizai 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 1 int i = rand()%100;//i的取值范围就是从0到992 float f = i/100.0;//成功了1 int a[]={33,61,12,19,14,71,78,59};2 vector<int>aa(a,a+8);3 sort(aa.begin(),aa.end()); 1 //函数指针传递 2 #include<iostream> 3 #include<algorithm> 4 #include<vector> 5 using namespace std; 6 int bitSum(int a); 7 bool les 阅读全文
posted @ 2013-06-05 21:56 herizai 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 void mySort(int *b,int size);2 void f()3 {4 int a[]={3,5,7,1,8,4,9};5 mySort(a,sizeof(a)/sizeof(a[0]));//mySort()的用法6 } 1 //数组是不能直接复制的 2 //向量参数传递 3 #include<iostream> 4 #include<vector> 5 #include<fstream> 6 #include<sstream> 7 using namespace std; 8 typedef vector<int&g 阅读全文
posted @ 2013-06-05 20:57 herizai 阅读(177) 评论(0) 推荐(0) 编辑
摘要: vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。 为了可以使用vector,必须在你的头文件中包含下面的代码: #include <vector> vector属于std命名域的,因此需要通过命名限定,如下完成你的代码: using std::vector; vector<int> vInts; 或者连在一起,使用全名: std::vector<int&g 阅读全文
posted @ 2013-06-05 20:22 herizai 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include<conio.h> 3 #include <iostream> 4 #include <string.h> 5 void main() 6 { 7 int i,j,k,count; 8 char s1[100],s2[100]; 9 printf("Please enter main string:");10 gets(s1);11 printf("enter sub string:");12 gets(s2);13 count=0;14 for 阅读全文
posted @ 2013-06-04 07:34 herizai 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 1 //每次运行到 recv 就会堵在那所有的c都没出来。。 2 //只有最后一次,所有的c从后往前 一个一个输出,临时变量 都是在 栈里保存的。你这个递归 就像 进栈一样,先进去的后出来 3 #include<stdio.h> 4 void rev() 5 { 6 char c; 7 c=getchar(); 8 if(c=='$') 9 printf("%c",c);10 else11 { 12 rev();13 printf("%c",c);14 15 ... 阅读全文
posted @ 2013-06-02 23:06 herizai 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 void rev() 3 { 4 char c; 5 c=getchar(); 6 if(c=='$') 7 printf("%c",c); 8 else 9 { 10 rev();11 printf("%c",c);12 }13 }14 void main()15 {16 rev();17 }18 //------------ 1 #include <stdio.h> 2 #include <time.h> 3 #inc... 阅读全文
posted @ 2013-06-01 21:40 herizai 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 在前一节中曾提到过,C++中运行时的多态性主要是通过虚函数来实现的,而编译时的多态性是由函数重载和运算符重载来实现的。这一系列我将主要讲解C++中有关运算符重载方面的内容。在每一个系列讲解之前,都会有它的一些基础知识需要我们去理解。而运算符重载的基础就是运算符重载函数。所以今天主要讲的是运算符重载函数。 1.运算符重载是对已有的运算符赋予多重含义,使同一个运算符作用域不同类型的数据导致不同行为的发生。比如1 int i;2 int i1=10,i2=10;3 i=i1+i2;4 std::cout<<"i1+i2="<<i<<std::e 阅读全文
posted @ 2013-06-01 09:49 herizai 阅读(321) 评论(0) 推荐(0) 编辑
摘要: operator是C++的关键字,它和运算符一起使用,表示一个运算符函数,理解时应将operator=整体上视为一个函数名。这是C++扩展运算符功能的方法,虽然样子古怪,但也可以理解:一方面要使运算符的使用方法与其原来一致,另一方面扩展其功能只能通过函数的方式(c++中,“功能”都是由函数实现的)。一、为什么使用操作符重载?对于系统的所有操作符,一般情况下,只支持基本数据类型和标准库中提供的class,对于用户自己定义的class,如果想支持基本操作,比如比较大小,判断是否相等,等等,则需要用户自己来定义关于这个操作符的具体实现。比如,判断两个人是否一样大,我们默认的规则是按照其年龄来比较,所 阅读全文
posted @ 2013-05-31 23:34 herizai 阅读(642) 评论(0) 推荐(0) 编辑
摘要: 在前一节中曾提到过,C++中运行时的多态性主要是通过虚函数来实现的,而编译时的多态性是由函数重载和运算符重载来实现的。这一系列我将主要讲解C++中有关运算符重载方面的内容。在每一个系列讲解之前,都会有它的一些基础知识需要我们去理解。而运算符重载的基础就是运算符重载函数。所以今天主要讲的是运算符重载函数。 1.运算符重载是对已有的运算符赋予多重含义,使同一个运算符作用域不同类型的数据导致不同行为的发生。比如1 int i;2 int i1=10,i2=10;3 i=i1+i2;4 std::cout<<"i1+i2="<<i<<std::e 阅读全文
posted @ 2013-05-31 09:42 herizai 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 class Boat;//必须事先声明 3 class Car 4 { 5 int size; 6 public: 7 void setSize(int j){size=j;} 8 int getSize(){return size;} 9 friend int leisure(int time,Car& aobj,Boat& bobj);10 };11 class Boat:Car//此处的Car可要可不要12 {13 int size;14 public:15 void setSize(int ... 阅读全文
posted @ 2013-05-30 22:01 herizai 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 现有一个四角为黑色方格的(2m+1)*(2n+1)的棋盘(红黑相间),证明:若删去任意一个红色的方格和任意两个黑色的方格,留下的棋盘一定可以被多米诺骨牌(即1*2的矩形)所覆盖。我先把它转化为二分图匹配问题,想用hall定理,但没成功,不知道这个题应该怎么解利用数学归纳即可,m=n=1时 只需要考虑6种情形,而这6种情形容易画出都能被1*2矩形所覆盖再假设(2k1+1)(2k2+1)是满足被覆盖的,考虑一个宽长为2边沿矩形之后与归纳连接下 阅读全文
posted @ 2013-05-29 22:41 herizai 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 class Myclass 4 { 5 int number; 6 public: 7 Myclass(); 8 Myclass(int); 9 ~Myclass();10 void Display();11 };12 Myclass::Myclass(){cout<<"Constructing nurmally.\n";}13 Myclass::Myclass(int m):number(m){cout<<"Constructing w 阅读全文
posted @ 2013-05-29 14:06 herizai 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<string> 3 using namespace std; 4 //----------------- 5 class GNumber 6 { 7 char chuan[50]; 8 public: 9 void set();10 friend int search (GNumber& str);11 };12 //-------------------13 int search(GNumber& s)14 { 15 int num=0; /... 阅读全文
posted @ 2013-05-28 17:52 herizai 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 把弹簧朝下,另一面朝自己,排线顺序有两类,A类和B类,B类是橙白、橙、绿白、蓝、蓝白、绿、棕白、棕。A类是绿白、绿、橙白、蓝、蓝白、橙、棕白、棕。 而你的网线制作的时候要选择A类还是B类,这个要看你的网络环境,一般电脑直接接到电脑之类的对等网,网线一头是A类,另一头是B类,如果是电脑接到交换机或者hub则两头都是B类或者是A类,一般习惯上多数都是做成B类。 另外需要注意的是,有些朋友做网线不喜欢按照标准来做,而是喜欢按照自己的习惯来排列顺序,这样做虽然网线也会通,但是可能会影响网络数据传输的速率,网线之所以要用双绞线是因为它的形状可以有效的减少干扰。如果顺序错了可能会使这种抗干扰能... 阅读全文
posted @ 2013-05-28 17:38 herizai 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream>//字符串排序 2 #include <string> 3 using namespace std; 4 void main() 5 { 6 void sort(string &,string &,string &); 7 string a,b,c; 8 string a1,b1,c1; 9 cin>>a>>b>>c;10 a1=a;b1=b;c1=c;11 sort(a1,b1,c1);12 cout<<a1<<" "< 阅读全文
posted @ 2013-05-27 17:16 herizai 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 #define size 5 5 int a[][2]={{2,3},{1,3},{3,1}}; 6 int b[][3]={{1,-2,-3},{2,-1,0}}; 7 8 int r[][3]={{0,0,0},{0,0,0},{0,0,0}}; 9 10 void f(int (*)[2],int (*)[3] )11 {12 for(int i=0;i<3;i++)13 {14 for(int j=0;j<3;... 阅读全文
posted @ 2013-05-27 16:11 herizai 阅读(225) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;class Vector{ int x,y;public: Vector(){};//默认构造函数 Vector(int x1,int y1)//重载构造函数 { x=x1;y=y1; } Vector operator+(Vector v)//成员函数方式重载运算符"+" { Vector tmp;//定义一个tmp对象 tmp.x=x+v.x; tmp.y=y+v.y; return tmp;//返回tm... 阅读全文
posted @ 2013-05-27 14:24 herizai 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<string> 3 using namespace std; 4 //----------------- 5 class GNumber 6 { 7 char chuan[50]; 8 public: 9 void set();10 friend int search (GNumber& str);11 };12 //-------------------13 int search(GNumber& s)14 { 15 int num=0; /... 阅读全文
posted @ 2013-05-27 14:22 herizai 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 面向对象程序设计试题A一、选择题(每小题1分,共10分)1.下列关于内联函数的描述中,错误的是( )。CA. 内联函数主要解决程序的运行效率问题;B. 内联函数的定义必须出现在内联函数第一次被调用之前;C. 内联函数中可以包括各种语句;D. 对内联函数不可以进行异常接口声明;2.下列( )不是构造函数的特征。DA. 构造函数的函数名与类名相同B. 构造函数可以重载C. 构造函数可以设置缺省参数D. 构造函数必须指定类型说明3.关于成员函数特征的下列描述中,( )是错误的。A A. 成员函数一定是内联函数 B. 成员函数可以重载 C. 成员函数可以设置缺省参数值 D. 成员函数可以是静态的4.下 阅读全文
posted @ 2013-05-27 13:19 herizai 阅读(554) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 #define AGE 18 4 #define MY_AGE 25 5 #define DISPY "已经被定义" 6 #define DISPN "尚未定义" 7 void main() 8 { 9 #ifdef AGE//判断AGE是否已被定义10 cout<<"AGE="<<AGE<<DISPY<<endl;//如果有11 #else12 cout<<DISPN&l 阅读全文
posted @ 2013-05-24 17:36 herizai 阅读(478) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-24 17:07 herizai 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 第3章C++数据类型第3章C++数据类型 本章将概括介绍 C++中预定义的内置的、或基本的数据类型。本章将以文字常量(literalconstant)开始,如 3.14159 和“pi”,然后介绍符号变量(symbolic variable)或者对象(object)的概念。C++程序中的对象必须被定义为某一种特定的类型,本章的余下部分将介绍可以用来声明对象的各种类型。另外,我们还将把 C++内置的对字符串与数组的支持与 C++标准库提供的类抽象进行对比。虽然标准库中的抽象类型不是基本类型,但是它们也是实用 C++程序的基础。我们希望尽早地介绍它们,以此来鼓励和说明它们的使用。我们把这些... 阅读全文
posted @ 2013-05-24 14:07 herizai 阅读(2011) 评论(0) 推荐(0) 编辑
摘要: 90年代以来,面向对象的程序设计( Object-Oriented Programming,简称OOP)异军突起,迅速在全世界流行,一跃成为主流的程序设计技术。在软件市场中,覆盖面大、垄断市场的新一代程序设计语言、软件开发工具和环境以及操作系统大多是面向对象的。10.1 面向对象的概念10.1.1 面向对象的程序结构面向对象的程序设计是一种基于结构分析的、以数据为中心的程序设计方法。在面向对象的程序中,活动的基本单位是对象,向对象发送消息可以激活对象的行为。为此,许多人把面向对象的程序描述为:程序=对象+消息传递1. 对象对象类似于 C语言中的变量,可以泛指自然界中的任何事务,包括具体实物和抽 阅读全文
posted @ 2013-05-24 14:02 herizai 阅读(310) 评论(0) 推荐(0) 编辑
摘要: //-------------------------------------// Stack.h//-------------------------------------const int SIZE = 10;//size初始化为10//-------------------------------------class Stack{ int stck[SIZE]; //holds the stack int tos; //index of top-of-stackpublic: Stack():tos(0){}//tos即栈的顶部初始化为0 ... 阅读全文
posted @ 2013-05-24 13:54 herizai 阅读(157) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-23 21:45 herizai 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-23 21:22 herizai 阅读(0) 评论(0) 推荐(0) 编辑
摘要: C++ 1 #include<iostream> 2 #include<ctime> 3 using namespace std; 4 int day_tab[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,28,31,30,31,30,31,31,30,31,30,31}}; 5 class Date 6 { 7 int year; 8 int month; 9 int day;10 public:11 Date()//默认构造函数:获取当前日期12 {13 char tmpbuf[1... 阅读全文
posted @ 2013-05-23 19:53 herizai 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 当参数为非const引用时,编译器就认为这个参数必须是可以修改的。_strdate参数datestr 05_23_12必须指向一个格式化的时间字符串(A pointer to a buffer containing the formatted date string)不能为空char *_strda... 阅读全文
posted @ 2013-05-23 19:51 herizai 阅读(293) 评论(0) 推荐(0) 编辑
摘要: //字符串连接函数char*strcat(char *strDestination,const char *strSource);strcat函数将字符串strSource连接到字符串strDestination,并且在strDestination字符串末尾添加NULL字符。函数结果会改变字符串strDestination,其将用来存储连接之后的字符串。函数不对内存溢出进行检查,所以要确保strDestination指向的空间足够长,以存储连接之后的字符串。如果strDestination和strSource指向的地址有重叠,函数结果未定义(不可预期)。返回值:strcat函数返回目标字符串的 阅读全文
posted @ 2013-05-23 17:20 herizai 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 1 VC6.0 2 3 #include<iostream> 4 using namespace std; 5 class MyClass2 6 { 7 int n; 8 public: 9 MyClass2(int i){n=i;}10 operator ++(){n++;}//vc6.0支持,vs2012不支持11 operator++(int){n+=2;}12 void display()13 {14 cout<<"n="<<n<<endl;15 }16 };17 void main()18 {19 MyClass2 阅读全文
posted @ 2013-05-23 16:51 herizai 阅读(226) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;void main(){ char c; for(int n;cin>>c>>n;) { for(int i=1;i<=n;++i) cout<<string(n-i,' ')+string(2*i-1,c)+'\n'; for(int i=1;i<n-1;++i) cout<<string(i,' ')+string(2*n-1-2*i,c)+'\n'; }}#include< 阅读全文
posted @ 2013-05-23 14:17 herizai 阅读(127) 评论(0) 推荐(0) 编辑
摘要: // icmpscanning.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "winsock2.h"#pragma comment(lib,"ws2_32.lib")typedef struct lpHeader{ unsigned char Version_HLen;//首部长度 ,ip 版本号 unsigned char TOS; //服务类型tos unsigned short Length;//总长度 unsigned short Ident;//标示 unsigned 阅读全文
posted @ 2013-05-23 14:13 herizai 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 void input() 2 { 3 int row=3,col=3;//resize(),设置大小(size);reserve(),设置容量(capacity);size()是分配容器的内存大小, 4 //而capacity()只是设置容器容量大小,但并没有真正分配内存。 5 //打个比方:正在建造的一辆公交车,车里面可以设置40个座椅(reserve(40);),这是它的容量, 6 //但并不是说它里面就有了40个座椅,只能说明这部车内部空间大小可以放得下40张座椅而已。而车里面安装了40个座椅(resize(40);), 7 //这个时候车里面才真正有了40个座椅,这... 阅读全文
posted @ 2013-05-23 14:12 herizai 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<iomanip> 3 using namespace std; 4 class Matrix 5 { 6 int a[2][3]; 7 public: 8 Matrix(){}; 9 void setMatrixa();10 void setMatrixb();11 void getMatrix();12 friend Matrix operator+(Matrix& t,Matrix temp);13 };14 void Matrix::setMatrixa()15 {16 cout<< 阅读全文
posted @ 2013-05-23 12:22 herizai 阅读(190) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-23 12:09 herizai 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-23 12:08 herizai 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; class Student1 { int no; char *pname; public: Student1(){};//默认构造函数 Student1(int n,char *p)//重载构造函数 { no=n; pname=new char[10];//不用new分配空间时会出错 strcpy(pname,p); ... 阅读全文
posted @ 2013-05-22 21:49 herizai 阅读(162) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-05-22 21:35 herizai 阅读(2) 评论(0) 推荐(0) 编辑