123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include <iostream>
- #include <string>
- class datatype {
- public:
- datatype() {}
-
- void inputChar(char c) {
- std::cout << "character:" << c << std::endl;
- }
- void inputInt(int num) {
- std::cout << "int:" << num << std::endl;
- }
- void inputFloat(float f) {
- std::cout << "float:" << f << std::endl;
- }
- };
- int main() {
- int choice;
- std::cin >> choice;
- datatype obj;
- if (choice == 1) {
- int num;
- std::cin >> num;
- obj.inputInt(num);
- } else if (choice == 2) {
- char c;
- std::cin >> c;
- obj.inputChar(c);
- } else if (choice == 3) {
- float f;
- std::cin >> f;
- obj.inputFloat(f);
- }
- return 0;
- }
|