实现复数的+、-、*、/运算.要求:1.+、*为类运算符; 2.-、/为友元运算符实现复数的+、-、*、/运算.要求:1.+、*为类运算符;2.-、/为友元运算符;3.复数的实部和虚部为实数;4.输入输出格式
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/12 01:21:26
![实现复数的+、-、*、/运算.要求:1.+、*为类运算符; 2.-、/为友元运算符实现复数的+、-、*、/运算.要求:1.+、*为类运算符;2.-、/为友元运算符;3.复数的实部和虚部为实数;4.输入输出格式](/uploads/image/z/10255741-61-1.jpg?t=%E5%AE%9E%E7%8E%B0%E5%A4%8D%E6%95%B0%E7%9A%84%2B%E3%80%81-%E3%80%81%2A%E3%80%81%2F%E8%BF%90%E7%AE%97.%E8%A6%81%E6%B1%82%EF%BC%9A1.%2B%E3%80%81%2A%E4%B8%BA%E7%B1%BB%E8%BF%90%E7%AE%97%E7%AC%A6%EF%BC%9B+2.-%E3%80%81%2F%E4%B8%BA%E5%8F%8B%E5%85%83%E8%BF%90%E7%AE%97%E7%AC%A6%E5%AE%9E%E7%8E%B0%E5%A4%8D%E6%95%B0%E7%9A%84%2B%E3%80%81-%E3%80%81%2A%E3%80%81%2F%E8%BF%90%E7%AE%97.%E8%A6%81%E6%B1%82%EF%BC%9A1.%2B%E3%80%81%2A%E4%B8%BA%E7%B1%BB%E8%BF%90%E7%AE%97%E7%AC%A6%EF%BC%9B2.-%E3%80%81%2F%E4%B8%BA%E5%8F%8B%E5%85%83%E8%BF%90%E7%AE%97%E7%AC%A6%EF%BC%9B3.%E5%A4%8D%E6%95%B0%E7%9A%84%E5%AE%9E%E9%83%A8%E5%92%8C%E8%99%9A%E9%83%A8%E4%B8%BA%E5%AE%9E%E6%95%B0%EF%BC%9B4.%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E6%A0%BC%E5%BC%8F)
实现复数的+、-、*、/运算.要求:1.+、*为类运算符; 2.-、/为友元运算符实现复数的+、-、*、/运算.要求:1.+、*为类运算符;2.-、/为友元运算符;3.复数的实部和虚部为实数;4.输入输出格式
实现复数的+、-、*、/运算.要求:1.+、*为类运算符; 2.-、/为友元运算符
实现复数的+、-、*、/运算.
要求:
1.+、*为类运算符;
2.-、/为友元运算符;
3.复数的实部和虚部为实数;
4.输入输出格式如下:
请输入一个复数的实部 虚部
1 1
请输入一个复数的实部 虚部
2 2
实现复数的+、-、*、/运算.要求:1.+、*为类运算符; 2.-、/为友元运算符实现复数的+、-、*、/运算.要求:1.+、*为类运算符;2.-、/为友元运算符;3.复数的实部和虚部为实数;4.输入输出格式
#include<iostream>
using namespace std;
// 声明一个共同的基类Person
class Person
{
protected:
float age;
char name[20], sex;
public:
Person()
{
cin >> name >> age >> sex;
}
void output() // 定义信息输出函数output
{
cout << " " << name << " " << sex << " " << age;
}
};
// 声明虚基类Person的派生类——大学生类Student
class Student:virtual public Person
{
protected:
char major[20];
public:
Student()
{
cin >> major;
}
void printf()
{
cout << endl << endl << "";
}
};
int main()
{
cout << "Please input a student information:" << endl << "Name Age Sex Major" << endl;
Student a;
cout << endl<<"Please input a employee information:" << endl << "Name Age Sex Department" << endl;
Emploree b;
cout << endl << "Please input a working student:" << endl << "Name Age Sex Department Tutor" << endl;
E_student c;
a.printf();
b.printf();
c.printf();
return 0;
}