- 博客(10)
- 资源 (4)
- 收藏
- 关注
原创 C++派生类构造函数调用顺序
#include using namespace std;class A{public: A() { a=0; cout } A(int i) { a=i; cout } ~A() {
2012-08-28 16:12:00 474
原创 友元函数实例
#include using namespace std;class Cla{public: Cla(double d = 0) { dat = d; } friend void inDat(Cla &d) { cin >> d.dat; } friend Cla addDat(Cla d1,Cla d
2012-08-27 17:55:35 2281
原创 静态成员函数生命期
块级别的局部静态对象其作用域局部于块,但其生命周期与全局对象相同 ,只是在第一次遇见时分配空间并初始化。具体情况见实例:#include #include using namespace std;int count = 0 ;class myclass{ char cc;public: myclass(char ch) { ++co
2012-08-24 10:52:50 621
原创 函数指针实例
#include #include using namespace std;double func1(double x){ cout return (1/x);}double func2(double x){ cout return (x*x);}double func3(double x){ cout
2012-08-23 16:34:41 413
原创 int* p 与 int** p的区别
#include using namespace std;int func(int i1,int* pi21,int* &pi22,int &ri3,char* str){ cout cout << "i1,*pi21,*pi22,ri3,str = " << i1 << " " << *pi21 << " " << *pi22 << " " << ri3
2012-08-23 15:04:29 795
原创 new delete的简单用法
#include using namespace std;int main(){ struct str { int a[10000]; }; str* temp; int count = 0; cout for(int i = 0;i { count++; temp = new str[1
2012-08-23 10:32:26 425
原创 简单排序算法
#include #include void Sort(int A[],int n){ int i = 1; int ind; int temp = 0 ; for(i = 1;i { ind = i; temp = A[i]; while(ind > 0 && temp { A[ind] = A[ind
2012-08-22 10:46:45 382
原创 shell脚本读取配置文件
#!/bin/shpack_install(){ echo "hello" if [ $3 = "\"y\"" ];then salt "$2" cmd.run "apt-get install --force-yes -y $1" 1>/dev/null 2>&1 fi}pack="elasticsearch"var=$(awk -F '=' '/\
2012-08-21 17:23:18 1194
转载 waitpid实例
#include #include #include #include #include int main(){ pid_t childpid,a; int status; childpid = fork(); printf("childpid = %d\n",childpid); if ( childpid
2012-08-21 10:23:14 526
转载 线程同步
生产者而消费者的同步问题: #include #include #define BUFFER_SIZE 16 // 缓冲区数量struct prodcons{// 缓冲区相关数据结构 int buffer[BUFFER_SIZE]; /* 实际数据存放的数组*/ pthread_mutex_t lock; /* 互斥体lock 用于对缓冲区的互斥操作
2012-08-20 15:51:32 377
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人