自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 C++单继承情况下派生类的虚函数表

上述过程,通过指针b1,derived2 虚函数表被 derived 虚函数表所对应的内存切割。可见: 基类和各级派生类的虚函数列表按先后顺序排列。

2024-03-22 22:15:42 182

原创 vs下debug监视窗口中虚函数表显示不全

2024-03-22 20:50:23 80 1

原创 C++ virtual析构函数

结论:需要将用于多态作用的基类声明一个virtual析构函数,由该基类得到所有的派生类的析构函数自动成为virtual析构函数。derived 类:(析构函数可以加或者不加virtual,没有影响)base 类:(设置虚析构函数)

2024-03-20 16:07:18 198 1

原创 MKL库: cblas_dgemv

#include "mkl.h"#include <stdio.h>#include <iostream>using namespace std;int main(){ int i = 0; double A[6] = { 1.0, 2.0, 1.0, -3.0, 4.0, -1.0 }; double b[2] = { 1.0, 2.0}; double a[3] = { 0.0 }; //在列展开下,不管A是否转置,lbda:A矩阵的行数 /*按列.

2020-11-16 20:30:23 1339

原创 MKL库:cblas_dgemm 之一

#include "mkl.h"#include <stdio.h>#include <iostream>using namespace std;int main(){ int i = 0; double A[6] = { 1.0, 2.0, 1.0, -3.0, 4.0, -1.0 }; double B[6] = { 1.0, 2.0, 1.0, -3.0, 4.0, -1.0 }; double C[9] = { 0.0 }; double D[9] .

2020-11-16 17:13:02 1341

原创 C++ 之异常机制分析

https://www.cnblogs.com/QG-whz/p/5136883.html

2020-11-07 22:16:37 98

原创 C++之virtual虚函数的几种用法

1. virtual functionbase class(virtual ), derived class(override)2. virtual destructor3. pure virtual functionit is Claimed in base class without implementation, and enforce the subclass (derived class) to implement

2020-11-04 21:12:45 553

原创 编写高效实用的C++程序

在编写程序时,注意:don't use "namepace std" 降低各文件之间的相关性。 尽量多的使用const关键词。 对于常量判断,选择switch...case代替if...else... ??? 用引用传值代替指针传值??? 构造函数尽量使用member initialization list,替代赋值操作。 为免除“跨编译单元的初始化次序”问题,用local static 代替 non-local static 对象。...

2020-11-03 13:48:58 182

原创 C++之enum用法简介

代码:#include <iostream>using namespace std;enum fruit { apple, oringe, banana, watermelonl} myfruit;int main(){ myfruit = banana; switch (myfruit) { case apple: cout << "apple is here.\n"; break; case banana: cout <<

2020-10-31 12:26:04 642

原创 C++线程库学习

https://zh.cppreference.com/w/cpp/thread

2020-10-27 16:52:23 52

原创 C++读入文件txt并把值储存到相应的变量中(针对复杂格式的txt文本)

使用fgets(char* buf, sizeof(buf), FILE* stream) 以及 sscanf (const char *str,const char * format,........)。这里要了解format格式的正则表达式写法。针对如何在C++读入以下复杂text 文本:运行结果(保存在几个数组中用printf输出来的结果):附上代码:#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#inclu.

2020-10-15 16:17:08 2424

原创 C++ 中如何在类Class中建立以struct为元素的vector模板?

代码:#include <iostream>#include <vector>using namespace std;class JointClass;//---------------------------------------------class INFO{public: struct Rect { int Ini; int* MarkerI; int* MarkerJ; JointClass* ptrClass; }; Rec

2020-08-03 17:35:19 419

原创 C++如何使用函数进行多维数组的内存分配和释放?

直接给出代码:#include <iostream>#include <mkl.h>void DeAllocateMemoryD(double*(&ptr));void AllocateMemoryD(double*(&ptr));void AllocateMemory2D(double** & rr, int row, int column);void DeAllocateMemory2D(double** & rr, int ro

2020-07-27 12:09:57 380

转载 MATLAB导入txt文件并画图

https://blog.csdn.net/libin957895408/article/details/10165319

2020-07-23 11:37:28 2581

原创 C++如何在文件中保存数据并对齐?

代码:#include <iostream>#include <fstream>#include <iomanip>using namespace std;int main(){ double a = -1; double b = 1; int n = 200; double n_x = (b - a) / n; double x[200],y[200]; ofstream outfile("output.txt"); for (i.

2020-07-23 11:02:34 2224 3

原创 如何对字符串进行逻辑判断?

对字符串的逻辑判断有两种旧接口C和C++接口两种,前者需要借助strcmp().#include <iostream>#include <string>using std::string;class A{public: A(char * Trans) { m_Trans = Trans; } void compare() { if (strcmp(m_Trans, "Quaternion") == 0) { std::cout <

2020-07-22 09:59:45 819

原创 如何访问类中private变量?

只有类中的成员函数和友元类(函数)可以访问类中的private变量!!!routineclass Apple{ friend class Banana;public: Apple(double input) //constructer { m_a = input std::cout<<m_a<<std::endl; }private: double m_a;}class Banana

2020-07-22 09:53:03 2160

原创 如何在类的函数中返回数组?

方法:采用指针和静态static。routines:#include <iostream>class test{public: double* mytest(double *input) { static double A[2]; A[0] = input[0]; A[1] = input[1]; return A;

2020-07-22 09:39:20 546

原创 C语言编程习惯

尽量使用一级指针,不要使用二级指针在子函数内部尽量不要分配内存;分配内存后要释放不要用指针覆盖另一个指针

2019-06-12 16:40:43 240

原创 C/C++之pointer

Refer to new memory reserved during program executionRefer and share large data structures without making a copy of the structuresTo specify relationship among data-linked lists, trees, graphs...

2019-06-11 21:24:09 243

原创 C++之Stack vs Heap

一、预备知识—程序的内存分配一个由C/C++编译的程序占用的内存分为以下几个部分1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。3、全局区(.........

2018-11-09 09:18:05 110

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除