typedef enum {
Operation_AND,
Operation_OR,
Operation_NOT,
...
} Operation_Key;
map<Operation_Key, pair<int, int>> operators_sw_map; //use in initialize method
switch(it->first)
{
case Operation_AND:
...
}
#include <iostream>
#include <ncurses.h>
using namespace std;
string get_string()
{
string result;
while(true) {
int c = getch();
if (c == -1)
continue;
if (c == 10)
break;
if (c == 127) {
if (result.length() > 0) {
result = result.substr(0, result.length() - 1);
clear();
addstr("Enter name: ");
addstr(result.c_str());
}
}
else if (c > 33 && c < 127) {
result += (char) c;
addch(c);
}
}
return result;
}
int main() {
initscr();
noecho();
addstr("Enter name: ");
string name = get_string();
endwin();
cout << endl << name << endl;
return 0;
}
char* insert_char(char* str, uint_t pos, char ch)
{
uint_t len = strlen(str);
char* new_str = new char[len+1];
if (pos != 0)
memcpy(new_str, str, pos * sizeof(char));
new_str[pos] = ch;
if (pos != len)
memcpy(&(new_str[pos+1]), &str[pos], (len - pos) * sizeof(char));
return new_str;
}
#if !defined(__MAIN_H_INCLUDED__) // Это чтобы файл не парсился несколько раз
// при компиляции одного cpp-файла
#define __MAIN_H_INCLUDED__
int main(); // Форвард-определения функций
extern int x; // Внешние определения переменных
const int y = 0; // Константы
template <class _T> // Шаблоны классов и функций содержат тела функций
class ClassT {
public:
ClassT()
{ }
};
inline int get_x() { // Инлайновые функции тоже тело находится в заголовке
return x;
}
#endif // __MAIN_H_INCLUDED__