细腻期待

文章
8
资源
0
加入时间
3年2月3天

C++中static的一种应用:单例模式

单例模式:设计模式的一种,保证某个类永远只创建一个对象1.构造函数私有化2.定义一个私有的static成员变量指向唯一的那个单例对象3.提供一个公共的访问单例对象的接口#include <iostream>using namespace std;class Person {private: static Person* teacher; //定义一个唯一的对象 Person() {} //构造函数私有化 Person(const Person&a

机器人路径(DP)

点击打开链接分有避障和无避障#include<iostream>#include <vector>using namespace std;int count_ways(int M,int N) //无障碍{ vector<vector<int>>dp(M,vector<int>(