Ths_ye 2015-12-07 16:37 采纳率: 66.7%
浏览 1527
已采纳

初学者提问,关于c++中class的问题

#include using namespace std;enum Type{HOME, OFFICE, FAX, CELL, PAGER};class PhoneNum{public: PhoneNum() { country_code = 0; area_code = 0; num = 0; type = HOME; } PhoneNum(int, int, int, Type); PhoneNum(int, Type); int GetCountryCode() const; int GetAreaCode() const; int GetPhoneNum() const; Type GetType() const; void SetCountryCode(int); void SetAreaCode(int); void SetPhoneNum(int); void SetType(Type); bool Equal(PhoneNum);private: int country_code; int area_code; int num; Type type;};PhoneNum :: PhoneNum(int a, int b, int c, Type t){ a = country_code; b = area_code; c = num; type = t;}PhoneNum :: PhoneNum(int d, Type t1){ num = d; type = t1; country_code = 86; area_code = 20;}int PhoneNum :: GetCountryCode()const{ return country_code;}int PhoneNum :: GetAreaCode() const{ return area_code;}int PhoneNum :: GetPhoneNum()const{ return num;}Type PhoneNum ::GetType()const{ return type;}void PhoneNum ::SetCountryCode(int f){ country_code = f;}void PhoneNum ::SetAreaCode(int g){ area_code = g;}void PhoneNum ::SetPhoneNum(int h){ num = h;}void PhoneNum ::SetType(Type t3){ type = t3;}bool PhoneNum ::Equal(PhoneNum n) { return((country_code == n.country_code) && (area_code == n.area_code) && (num == n.num) && (type == n.type));}
找不出代码问题,可提交了总是答案错误,求大神

  • 写回答

4条回答 默认 最新

  • ysuwood 2015-12-08 10:40
    关注

    4处错误:

     ComplexNum :: ComplexNum(double a, double b)
    {
        real = a;//修改
        imag = b;//修改
    }
    
    void ComplexNum :: divide(ComplexNum c4)
    {
        double c = real;
        double d = imag;
        real = (c * c4.real + d * c4.imag) / (c4.real * c4.real + c4.imag * c4.imag);//修改
        imag = (d * c4.real - c * c4.imag) / (c4.real * c4.real + c4.imag * c4.imag);//修改
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划