if(p->RoomsCount==p->ptr->RoomsCount) // ptr == nullptr;
struct OLS
{
int RoomsCount;
int floor;
float square;
OLS *ptr;
friend bool operator==(OLS& a, OLS& b);
};
typedef OLS* pOLS;
bool operator==(OLS& a, OLS& b)
{
return (a.RoomsCount == b.RoomsCount) &&
(a.floor == b.floor) &&
(a.square != b.square);
}
void CompAndFind(pOLS& str)
{
if(!str) return;// nullptr
pOLS p = str;
while(p->ptr)
{
if(*p == *(p->ptr))
{
show(p);
}
p = p->ptr;
}
}
QStandardItemModel *model = new QStandardItemModel();
for (auto& x : tx->AddrsTo)
{
Qstring s(x.c_str());
QStringList items = s.split(';');
int sz = items.size();
for(int i = 0; i < sz; ++i)
{
model->setItem(0, i, new QStandardItem(items[i]));
}
}
this->findChild<QTableView*>("Adresses_tableView")->setModel(model);
QBuffer::QBuffer(QByteArray *byteArray, QObject *parent = nullptr)
QByteArray ba;
int n = 63;
ba.setNum(n); // ba == "63"
QBuffer buffer(&ba);
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
template<typename Container, typename value>
bool remove_value(Container& c, value v)
{
if(auto it{find(begin(c), end(c), v)}; it != end(c))
{
c.erase(it);
return true;
}
return false;
}
int main()
{
list<int> myList {1,2,3,4,5,6,7,8,9,10};
//myList.erase(std::remove(myList.begin(), myList.end(), 7));
/*if(auto it{find(myList.begin(), myList.end(), 7)}; it != myList.end())
{
myList.erase(it);
}*/
if(int value = 7; remove_value(myList, value))
{
cout << "removed value: " << value << endl;
}
else
{
cout << "value: " << value << " not found" << endl;
}
for(int v:myList)
{
std::cout << v << ' ';
}
}
Имеется некий Pawn, где в:
.h file:
#include “MyController.h”
...
AMyController * GameController; - никуда не указывает.
...
public:
void CursorManagment();
#include <iostream>
#include <conio.h>
using namespace std;
int i1 = 0;
class Test
{
int _id;
public:
Test(int id = i1++):_id(id)
{
cout << "Create Object: " << this << " _id: " << _id << endl;
}
~Test()
{
cout << "Delete Object: " << this << " _id: " << _id << endl;
if(i1) i1--;
}
void ShowID()
{
cout << "ShowID() " << this << " _id: " << _id << endl;
}
};
int main()
{
long int num;
cin >> num;
cout << endl;
Test *obj= new Test[num];
for(int i=0; i < num; ++i)
{
obj[i].ShowID();
}
delete[] obj;
_getch();
return 0;
}
БЕЗ материала для новичков
#include <QObject>
#include <QVector>
class Foo: public QObject
{
Q_OBJECT
Q_PROPERTY(QVector<bool> b READ getData WRITE setData)
public:
Foo()
{
m_b.resize(30);
for(auto &b:m_b)
{
b = true;
}
}
QVector<bool> getData()
{
return m_b;
}
void inv()
{
for(auto &b:m_b)
{
b = !b;
}
}
void setData(QVector<bool> b)
{
m_b = b;
}
private:
QVector<bool> m_b;
};
class Bar: public QObject
{
Q_OBJECT
Q_PROPERTY(QVector<bool> b WRITE setData)
public:
Bar(){};
void printData()
{
for(auto &b:m_b)
{
qDebug() << b << ' ';
}
}
void setData(QVector<bool> b)
{
m_b = b;
}
private:
QVector<bool> m_b;
};
int main(int argc, char *argv[])
{
Foo foo;
Bar bar;
bar.setData(foo.getData());
bar.printData();
qDebug() << "modify\n";
foo.inv();
bar.setProperty("b", foo.property("b"));
bar.printData();
}
using namespace std;
class Student
{
public:
string name;
string last_name;
string year;
string get()
{
string s = name + ',' + last_name + ',' + year;
return s;
}
};
int main(int argc, char* argv[])
{
Student student;
student.name="Ivan";
student.last_name="Ivanov";
student.year = "2001";
vector<Student> v1;
v1.push_back(student);
cout << v1[0].get();
}
void ReadLog(Parser& input, mutex &m) {
if (input.filename != "")
input.ReadLog(m);
}
void ParceEvents(Parser& input, mutex &m) {
if (input.filename != "")
input.ParseEvent( m);
}