![]() |
помогите пожалуста c программой на с++(сдавать срочно)
только начинаю осваивать Visual C++, написал часть программы - не знаю как доделать
Проект нужно сдавать через пару дней а я не знаю как завершить прогу, помогите кто может:wow: Заранее большое спасибо!!!! :sos: Задание: -The class is called “Worker”. -It has 3 private members: name (char type), age (integer type), salary(double type). -It has two constructors: one has no arguments and it initializes name with 'C', age with 20, and salary with 100.00; the other takes two arguments (char char1, int var_age) and it initializes name with char1’s value, age with var_age’s value, and salary with 200.00. -The class also has a member function access which outputs name’s value, age’s value, and salary’s value to screen. -The class has a friend function overloading operator == so that it will return true when comparing two objects of the same class Worker. For example, if wk1 and wk2 are two objects of class Worker and their 3 private members are same, (wk1= =wk2) will return true. -Write a main program to test your class implementation. Код:
Код:
Код:
|
Ответ: помогите пожалуста c программой на с++(сдавать срочно)
я б так написал...
#include <iostream> #include <cstdio> using namespace std; class Worker { char worker; int age; double salary; public: Worker(): worker('C'), age(20), salary(100.00) {} Worker(char char1, int var_age): worker(char1), age(var_age), salary(200.00) {} void output() { cout << "----------" << endl << "wolker: " << worker << endl << "age: " << age << endl << "salary: " << salary << endl; } friend bool operator==(const Worker&, const Worker&); }; bool operator==(const Worker &w1, const Worker &w2) { return w1.age == w2.age && w1.worker == w2.worker && w1.salary == w2.salary; } bool operator!=(const Worker &w1, const Worker &w2) { return !(w1 == w2); } int main() { Worker w1; Worker w2('A', 30); w1.output(); w2.output(); cout << endl; if (w1 == w2) cout << "equal"; else cout << "not equal"; cout << endl; return EXIT_SUCCESS; } |
Ответ: помогите пожалуста c программой на с++(сдавать срочно)
stich
друг спасибо большое:super:. сижу разбираюсь. |
| Текущее время: 20:58. Часовой пояс GMT +3. |
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2026, vBulletin Solutions, Inc. Перевод: zCarot
Copyright ©2004 - 2025 NoWa.cc