
c++学习笔记
位面元哥
三十功名尘与土 ,八千里路云和月
展开
-
c++学习笔记,c++类成员变量初始化顺序
文章目录1,c++类成员变量初始化顺序,和成员变量定义顺序保持一致,而和构造函数初始化列表中的顺序无关2,正确的写法1,c++类成员变量初始化顺序,和成员变量定义顺序保持一致,而和构造函数初始化列表中的顺序无关#include <iostream>class A { public: A(int a, int b):m_a(a), m_b(b),m_c(m_a + m_b) { std::cout << "m_a:" << m_a <原创 2020-05-12 20:06:10 · 304 阅读 · 0 评论 -
c++学习笔记,dynamic_cast,类的空指针问题,基类和派生类类型转换,(向上转换、向下转换)
1,定义两个有虚函数的基类,一个派生类实现这两个基类的虚函数#include <iostream>class A { public: virtual void fun_a() = 0;};class B { public: virtual void fun_b() = 0;};class C :public A, public B{ public: void fun_a() override final { std::cout << "fu.原创 2020-05-12 09:39:58 · 2539 阅读 · 0 评论 -
c++学习笔记,for循环,i++,++i
代码 结果原创 2019-08-24 21:42:04 · 397 阅读 · 0 评论 -
c++学习笔记,c++结构体拷贝,c++深拷贝与浅拷贝
struct type { int i; std::string s; char *c; int a[2]; std::vector<int> v; std::map<std::string, int> m;};int main(){ std::cout << "hello" << st...原创 2019-08-26 12:17:21 · 1626 阅读 · 0 评论 -
c++学习笔记,c++获取线程ID,c++获取进程ID,gettid(), getpid(), getppid(), getuid(), getgid()
#include <stdio.h>#include <unistd.h>#include <sys/syscall.h>#define gettid() syscall(SYS_gettid).........printf("tid:%d, pid:%d, ppid:%d, uid:%d, gid:%d\n", gettid(), getp...原创 2019-08-27 12:23:11 · 1472 阅读 · 0 评论 -
c++学习笔记,c++获取cpu、内存使用情况,c++获取特定进程、线程的cpu、内存使用情况
#include<iostream> #include <unistd.h>#include <sys/syscall.h>#define gettid() syscall(SYS_gettid)using namespace std; #define _LINE_LENGTH 300 bool GetCpuMem(float &...原创 2019-08-27 12:47:40 · 1587 阅读 · 0 评论 -
c++学习笔记,移位运算符,原码,反码,补码
#include <iostream>int main(){ uint a = 5; int b; int c; b = (-1) << 3; c = -1 ^ b; std::cout << "b:" << b << std::endl; std::cout <&l...原创 2019-08-27 19:37:46 · 280 阅读 · 0 评论 -
c++学习笔记,vector迭代器iterator,eraser()
vector通过迭代器,使用eraser()删除元素后,该元素后面的vector部分会一次往前移动。1,创建一个vector,放入元素,并通过迭代器打印 std::vector<int> test_list; for(int i=0; i<5; i++) { test_list.push_back(i); } for(st...原创 2019-08-28 17:27:30 · 2576 阅读 · 0 评论