04 2022 档案
摘要:错误:invalid initialization of reference of type 'const Quote&' from expression of type 'const key_type {aka const std::shared_ptr<Quote>}' 解释:用const st
阅读全文
摘要:将实现同一功能的多个算法封装成多个不同的类,调用时更加方便,且避免条件语句的使用。 使用Context类来决定要使用哪个算法类,使用多态实现。通过在构造Context类时指定哪个算法类来实现选择功能。 Strategy类为纯虚类,用来派生不同的算法类。 #include <iostream> usi
阅读全文
摘要:第一版: 简单实现 在int main 主函数中读取数据,使用switch语句分别进行操作。不同操作用类实现。 #include <iostream> using namespace std; static int num_a; static int num_b; static char op; v
阅读全文
摘要:#include <iostream> #include <stdio.h> using namespace std; int main(int argc, char *argv[]) { int a=0x1234; //小端 34 12 char c=(char)(a); //判断是大端还是小端,
阅读全文