SHARE
TWEET

Untitled

a guest Sep 19th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <wrl.h>
  3.  
  4. using namespace std;
  5.  
  6. struct Person {
  7.     char surname[15];
  8.     int first_year;
  9.     float mark;
  10. };
  11.  
  12. void OverloadedFunc(Person &person, char *surname = "Ivanov", int year = 2019, float mark = 4.5) {
  13.     strcpy(person.surname, surname);
  14.     person.first_year = year;
  15.     person.mark = mark;
  16. }
  17.  
  18. void OverloadedFunc(Person &person, int year, float mark = 4.3) { //surname = "Ivanov"
  19.     strcpy(person.surname, "Ivanov");
  20.     person.first_year = year;
  21.     person.mark = mark;
  22. }
  23.  
  24. void OverloadedFunc(Person &person, char *surname, float mark) { //year = 2019
  25.     strcpy(person.surname, surname);
  26.     person.first_year = 2019;
  27.     person.mark = mark;
  28. }
  29.  
  30. void OverloadedFunc(Person &person, float mark) { //surname = "Ivanov", year = 2019
  31.     strcpy(person.surname, "Ivanov");
  32.     person.first_year = 2019;
  33.     person.mark = mark;
  34. }
  35.  
  36. void OutPut(Person &person) {
  37.     for (int i = 0; i < sizeof(person); ++i) {
  38.         cout << "Surname: " << person.surname;
  39.         cout << "Year: " << person.first_year;
  40.         cout << "Mark: " << person.mark;
  41.         cout << "\n";
  42.     }
  43. }
  44.  
  45. int main() {
  46.     Person *person = new Person[100];
  47.     float mark = 4.9;
  48.  
  49.     OverloadedFunc(*person); //+++
  50.     OverloadedFunc(*person, "Petrov"); //-++
  51.     OverloadedFunc(*person, "Sidorov", 2018); // --+
  52.     OverloadedFunc(*person, "A", 2017, 4.8); //---
  53.  
  54.     OverloadedFunc(*person, 2017, 4.7); //+--
  55.     OverloadedFunc(*person, 2015); //+-+
  56.  
  57.     OverloadedFunc(*person, "B", float (4.4)); //-+-
  58.  
  59.     OverloadedFunc(*person, float (mark)); //++-
  60.  
  61.     OutPut(*person);
  62.  
  63.     return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top