const

C++ Primer问题总结(11)

孤人 提交于 2020-03-01 03:52:09
# include <iostream> # include <vector> # include <memory> using namespace std ; template < typename T > class BlobPtr ; template < typename T > class Blob ; template < typename T > bool operator == ( const Blob < T > & , const Blob < T > & ) ; template < typename T > class Blob { friend class BlboPtr ; friend bool operator == ( const Blob < T > & , const Blob < T > & ) ; public : typedef typename vector < T > :: size_type size_type ; Blob ( ) ; Blob ( initializer_list < T > il ) ; size_type size ( ) const { return data - > size ( ) ; } bool empty ( ) const { return data - > empty ( ) ; } void

深入理解ES6系列笔记之第一章《块级作用域绑定》

人盡茶涼 提交于 2020-03-01 03:27:38
块级作用域绑定 本文仅仅作为前端实习面试的笔记内容,因此不能完全保证内容正确性,如有错误,欢迎指正! var声明及变量提升(Hoisting)机制 在函数作用域或者全局作用域通过关键字var声明的变量,无论实际上在哪里声明,都会被当作 当前作用域 顶部声明的变量。 function getValue (condition) { if (condition) { var value = 'blue' // other operations return value } else { // 此处可以访问value变量,其值为undefined return null } // 此处可以访问value变量,其值为undefined } 在预编译阶段,JavaScript引擎会将上面代码修改成下面这个样子 function getValue (condition) { var value if (condition) { value = 'blue' // other operations return value } else { // 此处可以访问value变量,其值为undefined return null } // 此处可以访问value变量,其值为undefined } 可以看到,变量value的声明提升到目前 函数作用域 的顶部,初始化操作仍在原来位置

Xcode中macos开发导入opencv2

你说的曾经没有我的故事 提交于 2020-03-01 03:17:05
Undefined symbols for architecture x86_64: "_AVCaptureSessionPresetMedium", referenced from: CvCaptureCAM::startCaptureDevice(int) in opencv2(cap_avfoundation.o) "_AVFileType3GPP", referenced from: CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in opencv2(cap_avfoundation.o) "_AVFileTypeAppleM4V", referenced from: CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in opencv2(cap_avfoundation.o) "_AVFileTypeMPEG4", referenced from: CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int,

poj 2418 Hardwood Species

佐手、 提交于 2020-02-29 22:20:40
原题链接: http://poj.org/problem?id=2418 简单题。。 平衡树,写了个模板。。动态分配内存确实很慢。。。 1 #include<algorithm> 2 #include<iostream> 3 #include<string> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cstdio> 7 using std::string; 8 template<typename T> 9 class sb_tree{ 10 private: 11 struct Node{ 12 T data; 13 int s, c; 14 Node *ch[2]; 15 Node(const T&d) :s(1), c(1), data(d){} 16 Node() :s(0), c(0){ ch[0] = ch[1] = this; } 17 inline void push_up(){ 18 s = ch[0]->s + ch[1]->s + c; 19 } 20 inline int cmp(const T&v) const{ 21 return v == data ? -1 : v > data; 22 } 23 }*null, *root; 24 inline void rotate(Node* &x,

QLineSeries相关内容

荒凉一梦 提交于 2020-02-29 21:59:22
学习一下Qt Charts的折线图部分。参考书籍:Qt5.9 C++开发指南 效果图 头文件 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QtCharts/QChart> #include <QLineSeries> #include <QValueAxis> using namespace QtCharts; namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); public: //初始化界面数据 void InitForm(); //创建Chart void createChart(); //初始化Chart,赋值数据 void InitChart(); private slots: void on_rdoTop_clicked(); void on_rdoBottom_clicked(); void on_rdoLeft_clicked(); void on_rdoRight_clicked(); void on

自考新教材--p152

依然范特西╮ 提交于 2020-02-29 18:29:18
源程序: //"+"、"-"运算符重载 #include <iostream> using namespace std; class myComplex { private:   double real, imag; public:   myComplex();   myComplex(double x, double i);   void outCom();   myComplex operator-(const myComplex &c);   friend myComplex operator+(const myComplex &c1, const myComplex &c2);//声明友元函数 }; myComplex::myComplex() {   real = 0;   imag = 0; } myComplex::myComplex(double r, double i) {   real = r;   imag = i; } void myComplex::outCom() {   cout << "(" << real << "," << imag << ")"; } myComplex myComplex::operator-(const myComplex &c) {   return myComplex(this->real - c.real, this-

类似淘宝,京东sku选择,电商商品选择

对着背影说爱祢 提交于 2020-02-29 18:14:51
<template> <div class="wrap-sku"> <div class="product-box"> <div class="product-content"> <div class="product-delcom" v-for="(productItem,indexs) in list" :key="indexs"> <p>{{ productItem.name }}</p> <ul class="product-footerlist"> <!-- currentChoose[ProductItem.name] === oItem.name // 选中项对象中Key是否存在规格属性 存在就选上red 否则oItem.hasStock代表是否可以被选择,不能被选择就直接置灰色 --> <li v-for="(oItem,index) in productItem.items" :key="index" @click="clickSku(productItem.name, oItem)" :class="[currentChoose[productItem.name] === oItem.name ? 'activeStock' : oItem.hasStock ? 'isStock' : 'noStock']"> {{ oItem.name }} </li> <

C++中的匿名函数(译)

99封情书 提交于 2020-02-29 17:21:47
C++11最令人兴奋的特性之一就是能够创建匿名函数(lambda functions),有时也被称为闭包(closures)。这意味着什么?lambda function是一个可以内联写在代码里的函数(通常被传递给另一个函数,与函数对象(functor)和函数指针有相似的概念)。有了lambda,快速创建函数已经变得更容易,也意味着不仅可以在之前需要定义一个独立的命名函数时使用lambda function,而且也可以凭借快速创建简单的函数写出更多的代码。本文中我会先解释为什么lambda是很棒的,并会给出一些例子,然后简略阐述使用lambda时你所可以做的所有细节。 为什么lambdas让人震撼 假使有一个地址簿类,而且想要提供一个搜索方法。你可以提供一个简单的搜索函数,接受一个string作为参数并返回所有与该string参数相匹配的地址。有时是该类的用户所想要的,但要是他们仅想在域名中搜索,或更可能在用户名中搜索且忽略掉在域名中的结果呢?或许他们可能想要搜索所有同时出现在另一个列表中的邮件地址,有许多潜在地待搜索的感兴趣的事情。代替把这些所有的选择都构建到类里,岂不是更好提供一个接受确定邮件地址是否是感兴趣的过程作为参数的通用find方法?我先称该方法为findMatchingAddresses,且接受一个函数或类函数参数。 #include <string>

Android深入浅出之Binder机制

旧城冷巷雨未停 提交于 2020-02-29 17:07:08
Android 深入浅出之 Binder 机制 一 说明 Android 系统最常见也是初学者最难搞明白的就是 Binder 了,很多很多的 Service 就是通过 Binder 机制来和客户端通讯交互的。所以搞明白 Binder 的话,在很大程度上就能理解程序运行的流程。 我们这里将以 MediaService 的例子来分析 Binder 的使用: <!--[if !supportLists]--> l <!--[endif]--> ServiceManager ,这是 Android OS 的整个服务的管理程序 <!--[if !supportLists]--> l <!--[endif]--> MediaService ,这个程序里边注册了提供媒体播放的服务程序 MediaPlayerService ,我们最后只分析这个 <!--[if !supportLists]--> l <!--[endif]--> MediaPlayerClient ,这个是与 MediaPlayerService 交互的客户端程序 下面先讲讲 MediaService 应用程序。 二 MediaService 的诞生 MediaService 是一个应用程序,虽然 Android 搞了七七八八的 JAVA 之类的东西,但是在本质上,它还是一个完整的 Linux 操作系统

CameraService启动流程-获取ICameraProvider服务代理对象BpHwCameraProvider并由此获取所有相机设备代理对象BpHwCameraDevice的流程

感情迁移 提交于 2020-02-29 16:54:35
本文分析下CameraService获取ICameraProvider代理对象BpHwCameraProvider的流程,以方便后边分析CameraService与ICameraProvider的通讯方式及探究下其他进程是否也可以获取ICameraProvider,直接与ICameraProvider通讯(即直接和HAL通讯) cameraService启动时,调用的方法第一个方法: //frameworks\av\services\camera\libcameraservice\CameraService.cpp void CameraService::onFirstRef() { ALOGI("CameraService process starting"); BnCameraService::onFirstRef(); // Update battery life tracking if service is restarting BatteryNotifier& notifier(BatteryNotifier::getInstance()); notifier.noteResetCamera(); notifier.noteResetFlashlight(); status_t res = INVALID_OPERATION; /