上一页 1 2 3 4 5 6 7 ··· 17 下一页
摘要: using namespace cv; // Capture the Image from the webcam VideoCapture cap(0); // Get the frame Mat save_img; cap >> save_img; if(save_img.empty()) { s 阅读全文
posted @ 2022-06-16 10:40 Truman001 阅读(211) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <vector> template<typename T> std::vector<double> linspace(T start_in, T end_in, int num_in) { std::vector<double> linspa 阅读全文
posted @ 2022-06-16 10:39 Truman001 阅读(1032) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<assert.h> #include<vector> #include<chrono> int main() { int iter = 10000; std::vector<double> coeffs = { 4, 2, -2, 5, 0, 阅读全文
posted @ 2022-06-16 10:29 Truman001 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<vector> #include<math.h> std::vector<double> Polyval(std::vector<double> coeffs, std::vector<double> values) { std::vector 阅读全文
posted @ 2022-06-16 10:27 Truman001 阅读(466) 评论(0) 推荐(0) 编辑
摘要: C++类型转换 static_cast 任何具有明确定义的类型转换,只要不包含底层const,都可以使用static_cast example: int j=10; double value=static_cast<double>(j)/2; void *p =&d; //必须确保d是double类 阅读全文
posted @ 2021-07-24 22:15 Truman001 阅读(43) 评论(0) 推荐(0) 编辑
摘要: /* 优化string 复制的时候 仅复制引用,只有在修改内容时,才复制内容 即实现写时拷贝 */ class COWMyString { public: //默认参数 COWMyString(const char *str = "") :m_str(strcpy(new char[strlen(s 阅读全文
posted @ 2021-03-17 17:01 Truman001 阅读(196) 评论(0) 推荐(0) 编辑
摘要: class A { public: //静态函数,返回引用 static A &GetInstance() {//静态局部变量 static A s_instance; return s_instance; } private: //默认构造函数 A() = default; /* 拷贝构造函数 用 阅读全文
posted @ 2021-03-17 16:13 Truman001 阅读(57) 评论(0) 推荐(0) 编辑
摘要: /* 实现一个string满足基本用法 */ class MyString { public: //默认参数 MyString(const char *str=""):m_str(strcpy(new char[strlen(str)+1], str)) { } ~MyString(void) { 阅读全文
posted @ 2021-03-17 16:12 Truman001 阅读(93) 评论(0) 推荐(0) 编辑
摘要: /* 实现一个线程安全的队列 */ template <class T> class SafeQueue { public: SafeQueue(void):q(),m(),c() {} ~SafeQueue(void) {} // Add an element to the queue. void 阅读全文
posted @ 2021-03-17 16:06 Truman001 阅读(562) 评论(0) 推荐(0) 编辑
摘要: /* 智能指针的简单实现 */ template<typename T> class SamrtPtr { public: //构造函数 SamrtPtr(T* ptr = nullptr) :m_ptr(ptr) { if (m_ptr) { m_count = new size_t(1); } 阅读全文
posted @ 2021-03-17 16:04 Truman001 阅读(87) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 17 下一页