- 博客(3)
- 收藏
- 关注
原创 C++ 模板类和静态成员变量
C++ 模板类和静态成员变量当一个模板类产生不同的类时,每个类产生的对象共享static变量,静态成员变量作用于类层面#include <iostream>using namespace std;template <class T>class Tem {public: Tem() {} ~Tem() {} static int stat;};template <class T>int Tem<T>:: stat = 0;int
2021-02-20 20:22:35
963
原创 Undefined symbols for architecture x86_64 ld: symbol(s) not found
课设作业遇到的bug代码:// main.cpp#include <iostream>#include <vector>#include "func.hpp"#include "func.cpp"using namespace std;class A {public: A(int xx = 1) { x = xx;} ~A() {} void print() { cout << x << endl; }private: int
2020-08-15 22:30:44
223
原创 C++ 用vector 动态创建二维数组
用vector创建二维数组创建:vector<int> w(10, 1); // w: width 即列数vector< vector<int> > arr(9, w); // 9行10列 二维数组注意: 用一维数组给二维数组赋值时,两个 ‘>’ 要隔开赋值:可直接赋值arr[i][j] = 1;添加元素:在最后一行下面添加一行: arr.push_back(vector<int>(10, 1));在某一行末尾
2020-08-14 15:47:32
3347
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人