All the good time, there was some need for a language that I do not know absolutely. Actually, the task is necessary to make input and output for each type of variable. string accepts any input, double also accepts any number, but what about int? I made it so that it did not accept the string, but when you enter a real, the program breaks down. How to be in this situation? Here is the piece of the program ..
List<int> mylist(0); while (true) { int r; cout<<"Реализация списка для типа Int"<<endl; cout<<"1) Добавить элемент"<<endl; ................... cin>>r; if (r==0) {mylist.~List();break;} switch (r) { case 1: { int st; cout<<"Введите элемент"<<endl; while (!(cin >> st)) { cin.clear(); while (cin.get() != '\n'); cout << "Неверный ввод. Повторите." << endl; cout <<"Введите целое число "<< endl; } mylist.add(st); system("pause"); continue; } ....................... }
x = 10; x.is_a? Integer #truex = 10; x.is_a? Integer #truex = 10; x.is_a? Integer #true- QWD666atoifunction, or generate an error. - Flowneeedouble r; int i; ... cin >> r; i = r; if (i != r) error("Not integer"); ...double r; int i; ... cin >> r; i = r; if (i != r) error("Not integer"); ...double r; int i; ... cin >> r; i = r; if (i != r) error("Not integer"); ...- avpstrtol- it says there, where the integer value ended, and if there are any digits left after it or something else - consider the input incorrect. - Harry