- 博客(8)
- 收藏
- 关注
原创 收养孤儿进程的不是init问题,即pid不是1
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <unistd.h>int main(){ pid_t pid=fork(); if(pid<0) { printf("fork error!\n"); return -1; } else if(pid>0) { pi.
2022-05-21 17:47:38
134
原创 Linux学习 fork()函数
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <unistd.h>int main(){ for(int i = 0;i < 3;i++) { pid_t pid=fork(); if(pid<0) { printf("fork error!\n"); retur.
2022-05-21 15:40:35
145
原创 C++菱形继承内存模型
#include <iostream>using namespace std;class Animal{public: Animal(){} ~Animal(){} int m_A = 1;private: };class Needy : virtual public Animal{public: Needy(){} ~Needy(){}private:};class Horse :virtual public Animal{public:.
2022-05-03 21:29:24
920
原创 C++ 库函数strcat() 注意事项,申请char数组要记得初始化
在进行自定的MyString "+"运算符重载函数编写时,遇到问题void test01(){ MyString str1 = MyString("jack"); MyString str2 = MyString("rose"); cout << str1 << endl; cout << str2 << endl; MyString str3 = str1 + str2; //cout << str3 << end
2022-05-03 15:17:48
1103
原创 C++ const修饰指针 用法
常量指针 const int *p1 = &num1const 类型 *指针名 = &常量void test01(){ const int num1 = 0; const int num2 = 1; int num3 = 2; const int *p1 = &num1; // const int *(指向int常量类型的指针) p1 = &num2; //编译通过 *p1 = 3;//编译失败
2022-05-01 19:29:35
1151
原创 C++ 拷贝构造函数(简单介绍了匿名对象的生命周期)
Person类class Person{public: int age = 0; Person add(int a) { this->age += a; return *this; } Person () { cout << "construction func executing!!!" << endl; } Person(const Person &p) { cout << "copy func execut
2022-05-01 16:19:33
478
原创 cpp无法调用c代码(重载机制)
当main.c test.c 都是纯c文件编译和连接没问题正常运行main.c#include <stdio.h>#include <stdlib.h>#include "test.h"int main(){ show(); // printf("jshdfg"); system("pause");}test.c#include <stdio.h>#include "test.h"void show(){
2022-04-30 00:30:47
861
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人