设计模式 - Null Object(空对象)模式
flyfish
Null Object(空对象)模式是一种设计模式,它的主要思想是提供一个默认的空对象,以避免处理空指针的复杂逻辑。《Pattern languages of program design 3》书中…
1、引入
#include <iostream>using namespace std;int add(int a, int b) {return a b;
}float add(float x, float y) {return x y;
}int main() {int result add(3, 4);cout << "result " << result << endl;float result2 add(3.5…
//校验邮箱
public class TestEmail {public static void main(String[] args) {Scanner input new Scanner(System.in);//*号代表任意数量,放在0-9a-zA-Z后面,代表可以写任意数量的字母和数字//是邮箱的符号,接在刚刚那串的后面//|代表或&a…