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条)

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型