Advanced search
BlinCTJune 1, 2019, 9:20 a.m.

C++Замена define на enum

C++11

Всем привет. Есть такая необходимость уйти в одной реализации с использования define на эти параметры завернутые в enum

#define SG_IO_USE_DETECT 0
#define SG_IO_UNSUPP 1
#define SG_IO_USE_V3 3
#define SG_IO_USE_V4 4

static int sg_io_state = SG_IO_USE_DETECT;

switch (sg_io_state)
{
  case …
BlinCTApril 22, 2019, 4:21 p.m.

C++Чтение из стрима результата выполнения команды

C++11

Всем привет.
Пытаюсь найти способ (только не Си) как получить выхлоп какой нибуть консольной команды. Например fdisk -l или uname -a
ВРоде как в стандарте что то есть для выполнения команд и чтения из стрима, но чет не могу найти. Сишный способ нашел, ужасно...
Спасибо.

Evgenij LegotskojAug. 6, 2018, 2:52 a.m.

C++The idiom RAII and the principle of structured programming that a function must have one entry point and one exit point

template, lambda, C++11

The world of programming in C ++ in the new standards allows us to get up a variety of things, thanks to which we can safely abandon some old statements or principles, or simply flexibly approach these principles.

I would like to outline my view on the work of the RAII idiom and the C ++ 11 standard with respect to one established principle whose authorship is attributed to Edsger Dijkstra :

"The module (in this case the function) must have only one entry point and only one exit point"

For this principle, multiple returns in a function / method are contrary to the principles of structured programming for the following reasons:

  • the complexity of debugging code with the use of multiple returns returns increases with the number of these same return, that is, you never know when the function or method of an object just exited.
    the complexity of code support, when all the points of the call are not visible at the initial look at the function. Also, it is not known whether the code added to the end of the function will execute or not, especially if the program logic should always execute this code. That is, in the case of multiple returns, you will have to implement this code before every call to the return operator.

But modern C ++ has already changed significantly since the times of Dijkstra and the means of the latest C ++ standards allow to bypass or significantly level out the influence of the reasons that caused the formulation of the principles of structured programming.

Evgenij LegotskojJan. 2, 2018, 4:33 a.m.

C++C ++ - Tutorial 012. static_assert, checking for errors at compile time

C++11, static_assert

Exceptions are thrown during the execution of the program; if the error can be found at compile time, you can use static_assert , which tells you to correct the program code in key locations.

The use of static_assert will look like this.

static\_assert(4<=sizeof(int), "integers are too small"); // checking the size of an integer

The syntax is as follows: static_assert(A, B); Where

  • A - this is the condition under which the error will be thrown in the event that A is false
  • B - this is the text of the error message
Evgenij LegotskojDec. 14, 2017, 5:10 p.m.

QtQt/C++ - Tutorial 074. Generating pseudo-random numbers, using STD library random

QRandomGenerator, C++11, qrand, qsrand, Random, Qt

Generating random numbers may be needed, for example, to calculate weapon damage in a computer game or to represent a graph from random numbers.

Qt provides the qrand function for generating random numbers, and also, starting with Qt 5.10 , the QRandomGenerator class.

Let's see how random values can be obtained in Qt, and how random they are.

Fornex

Let me recommend you a great European Fornex hosting.

Fornex has proven itself to be a stable host over the years.

For Django projects I recommend VPS hosting

Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN

View Hosting
MP

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:60points,
  • Rating points-1
SI

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:60points,
  • Rating points-1
k

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:90points,
  • Rating points8
Last comments
H

Python: How to Test Internet Speed

In behalf of cinephiles who submit self-referential scares, these 10 movies iron crucial spirits at the audience — and themselves. The “Bay” franchise returned to theaters this weekend wit…
H

Python: How to Test Internet Speed

There may be no animus franchise that opens with as dull-witted and satiating a ritual as Scream. As the shaping followers’s logo appears on wall, we rather enter upon hearing the ringing of a l…
A
  • Andrew
  • Jan. 12, 2022, 11:41 a.m.

Qt/C++ - Lesson 038. Switching between windows in the Qt

Здравствуйте, а как сделать чтобы второе и третье окно не сохраняли свои параметры а создавались заного? Только начинаю изучать прогграмирование и пишу протенькую игру сделал 2 окна, одно с меню…
j
  • juvf
  • Dec. 28, 2021, 11:56 p.m.

Deploying Qt and QML Applications on Linux and Windows

написал приложение, холоворд на qt виджетах, без qml. Из визарда QtCreator. Собрал кросскомпилятором. Нужно перенести на таргет. juvf@juvf-VirtualBox:~/qtWs/test/imx6/release$ ~/CQtDeploye…
AO

Qt/C++ - Lesson 023. Moving QGraphicsItem on QGraphicsScene with mouse help

А есть возможность передавать координаты классу, что-бы он рисвал, допустим линию?
Now discuss on the forum
MS

Октуда берется user?

Я все понял, спасибо большое за помощь)
AB

Sorting the added QML elements in the ListModel

I am writing an alarm clock in QML, I am required to sort the alarms in ascending order (depending on the date or time (if there are several alarms on the same day). I've done the sorting …
VK

Как получить ссылку на обьект присылающий сигнал через сигнал/слот?

Вот и ответ: Спасибо Александру за подсказку. void Core::onLogin(QString m_login) { Worker *m_worker = qobject_cast (sender()); hashLogin.insert(m_login, m_wor…
v

подтвердить значение в SpinBox

Мне необходимо подтвердить значение в SpinBox нажатием клавиши Enter и перевести фокус на другое поле. self.doubleSpinBox.returnPressed.co nnect(self.pressedKeys) def pressedKeys(sel…

Сортировка по дате и времени QSortFilterProxyModel QSqlRelationalTableModel

Добрый день. Наследуйте модель сортировки от QSortFilterProxyModel и переопределите метод QSortFilterProxyModel::lessThan таким образом, чтобы вы забирали через индексы дату и в…
About
Services
© EVILEG 2015-2021
Recommend hosting TIMEWEB