c++
kidyme
这个作者很懒,什么都没留下…
展开
-
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 · 892 阅读 · 0 评论 -
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 · 191 阅读 · 0 评论 -
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 · 3226 阅读 · 1 评论