#include <iostream>
#include <string>
#include <functional>
class BaseVirtual{
private:
virtual int func(int v) = 0;
public:
int runFunc(int v){return func(v);};
virtual ~BaseVirtual() = default;
};
class MyClass: public BaseVirtual{
private:
int func(int v) override {
return v * 42;
};
public:
MyClass(){}
~MyClass(){
std::cout << "destructed MyClass" << std::endl;
};
};
class MyClass2: public BaseVirtual{
private:
int func(int v) override {
return v * 42 * 2;
};
public:
MyClass2(){}
~MyClass2(){
std::cout << "destructed MyClass2" << std::endl;
};
};
int main()
{
BaseVirtual *c = new MyClass();
std::cout << c->runFunc(2) << std::endl;
delete c;
c = new MyClass2();
std::cout << c->runFunc(2) << std::endl;
delete c;
return 0;
}
но, осознав сколько там предстоит работы
Temperature {
id: temp
value: 15
min: 10
max: 20
anchors.centerIn: parent
}
Temperature {
id: temp2
value: 20
min: 10
max: 20
anchors.left: temp.right
}
json js= R"({
"ts" : 1618405055,
"updates":
[
[6,43841776,53939],
[
4,
60002,
19,
43841776,
1509659737,
"t",
{
"from_admin":"43841776",
"title":" ... "
}
]
]
})"_json;
int v = js["updates"][1][0]; //вытаскиваем 4
#include <iostream>
#include <vector>
void func(const std::vector<std::vector<int>> &a)
{
for (int i=0; i<a.size(); i++)
{
for (int k=0; k<a[i].size(); k++)
{
std::cout << a[i][k] << std::endl;
}
}
}
//или
void func2(const std::vector<std::vector<int>> &a)
{
for (auto && s : a)
{
for (auto && v : s)
{
std::cout << v << std::endl;
}
}
}
int main()
{
std::vector<std::vector<int>> a = {
{1, 2, 3},
{3, 4, 3},
};
func(a);
func2(a);
}