Я заказал,но пока что в наличии не имеются
они означают, что слово употреблено в переносном смысле
В общем, если кто-то знает, где можно найти примеры "совершенного" кода на C++, в котором можно разобраться без полугодового погружения в предметную область, прошу поделиться.
#include<iostream>
#include<functional>
#include<map>
#include<string>
using namespace std;
class Client
{
map<string, function<void()>> functions;
void printThis()
{
cout << "this: " << this << endl;
}
public:
Client()
{
functions["printThis"] = [this]{ printThis(); };
}
void commandListener(const string& command)
{
if(auto it{ functions.find(command) }; it != functions.end())
{
it->second();
}
else
{
cout << "This command does not exist\n"
<< "Add this blank command? (y/n) ";
if(cin.get() == 'y')
{
addCommand(command);
cout << "Ok!" << endl;
}
}
}
void addCommand(const string& cmd, function<void()>&& fn = {})
{
if(functions.count(cmd) == 0)
{
functions[cmd] = fn;
}
}
};
int main()
{
Client cl;
cl.addCommand("printNumber42", [](){ cout << 42 << endl; });
cl.addCommand("printTextText", [](){ cout << "Text" << endl; });
cl.commandListener("printNumber42");
cl.commandListener("printTextText");
cl.commandListener("blank");
cl.commandListener("printThis");
system("pause");
}
Или, как в таких случаях подтвердить опыт и что говорить?
char array2[n] = { '2','1','4','5','3','-3','-1','-2','-4','-5' };
int array3[n] = atoi(array2);
#include<iostream>
#include<typeinfo>
int main()
{
std::cout << typeid('-3').name();
std::cin.get();
}
#include <stdio.h>
int keylog()
{
FILE* fp = fopen("test.log", "w");
if(!fp)
{
perror("File opening failed");
return 1;
}
puts("Ctrl+D (Linux) or Ctrl+Z (Windows) == EOF");
int c;
while((c = fgetc(stdin)) != EOF)
{
fputc(c, fp);
}
fclose(fp);
puts("Done!");
return 0;
}
int main()
{
return keylog();
}
А как задать argc argv в чтобы gtest подставлял их в main функцию