t->Info[0] = Inf;
std::cout << "Result: " << std::fixed << res;
Foo get_foo(const char *msg)
{
return Foo_2(msg);
}
const Foo &get_foo(const char *msg)
{
static Foo_2 foo2(msg);
return foo2;
}
#include <iostream>
#include <iomanip>
#include <memory>
class ISomeInterface
{
public:
virtual bool isFoo() const noexcept = 0;
};
class Foo : public ISomeInterface
{
public:
bool isFoo() const noexcept override { return true; }
};
class Bar : public ISomeInterface
{
public:
bool isFoo() const noexcept override { return false; }
};
int main()
{
// Or shared_ptr/make_shared
std::unique_ptr<ISomeInterface> foo = std::make_unique<Foo>();
std::cout << "Foo is Foo: " << std::boolalpha << foo->isFoo() << std::endl;
// Or shared_ptr/make_shared
std::unique_ptr<ISomeInterface> bar = std::make_unique<Bar>();
std::cout << "Bar is Foo: " << std::boolalpha << bar->isFoo() << std::endl;
return 0;
}
#include <stdio.h>
#include <iostream>
#include <typeinfo>
template <class T>
class A {
public:
A(){};
~A(){};
typedef T custom;
custom num = 1;
T get() {
return num;
}
void print() {
std::cout << get() << " " << typeid(num).name() << "\n";
}
};
class B : public A<float> {
public:
B() : A() { num = 2.f; };
~B(){};
};
int main() {
B b;
b.print();
return 0;
}
QEventLoop loop;
QFutureWatcher watcher = QConcurrent::run(someFunc);
connect(&watcher, &QFutureWatcher::finished, &loop, &QEventLoop::quit);
loop.exec();
auto result = watcher.result();