如何从本地PouchDB数据库导入/导出数据库?我需要保存我的本地数据库并在不同的平台上打开它.服务器端没有CouchDB.
为简单起见,只需传递部分代码即可.
class A {
public:
std::vector<int> & get(){ return myVector;}
const std::vector<int> & get() const {return myVector;}
private:
std::vector<int> myVector;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何涉及重载的const get方法.当我尝试创建const_iterator和调试代码时,它涉及非const方法.想要了解它的工作原理我使用以下代码段
A myA;
myA.get().push_back(1);
for (const auto& v: myA.get()) { } // it involve not const get method
Run Code Online (Sandbox Code Playgroud)
要么
std::vector<int>::const_iterator cit = myA.get().begin()
//it involves not const method
Run Code Online (Sandbox Code Playgroud)
要么
const std::vector< int > v = myA.get( );
// involves non-const method
Run Code Online (Sandbox Code Playgroud)
甚至我创建功能:
int constVector( const std::vector< int > &constVector )
{
return constVector[0];
}
int b = constVector( …Run Code Online (Sandbox Code Playgroud) var myCar2 = {
maxSpeed: 70,
driver: "Arnold",
drive: function(speed, time) {
console.log("speed " + (speed * time));
},
logbook: function(a , b) {
console.log("max speed " + this.maxSpeed + " " + this.drive(a , b));
}
};
myCar2.logbook(3 , 6);
Run Code Online (Sandbox Code Playgroud)
如果我运行该代码this.drive(a , b)是undefined.如何将变量传递给drive()函数使用logbook()?
javascript ×2
c++ ×1
const ×1
function ×1
object ×1
overloading ×1
pouchdb ×1
scope ×1
variables ×1