鱼C论坛

 找回密码
 立即注册
查看: 2730|回复: 11

[已解决]c++抽象类,程序一直崩溃,救救孩子吧

[复制链接]
发表于 2021-6-5 22:14:10 | 显示全部楼层 |阅读模式
60鱼币
为某公司设计雇员工资发放系统。
每个雇员的基本信息包括:姓名(name),工号(id)。
雇员的收入取决于雇员的类型。该公司共有四类雇员:
周薪雇员(SalariedEmployee):收入=固定周薪。
时薪雇员(HourlyEmployee):若工作40小时以下,收入=小时数*每小时薪水;若工作40小时以上,收入=40*每小时薪水+(小时数-40)*每小时薪水*150%。
佣金雇员(CommissionEmployee):收入=销售量*每个商品的销售佣金
带底薪佣金雇员(BasePlusCommissionEmployee):收入=底薪+销售量*每个商品的销售佣金
要求:建立雇员继承层次,每个类包含计算工资和显示输出的功能,可以计算和显示输出公司雇员(Employee)的每周收入。输出时要显示该类雇员的所有信息。(包括雇员类型、姓名、工号、工资各项明细),写出主函数测试各类。在雇员基本信息中增加雇员的生日(birthDate),并设计日期类(Date)来表示生日。在主函数中创建一个容器用来管理公司各种雇员对象,多态地计算并输出每个雇员的工资。如果雇员的生日在本月,就奖给该雇员100元。同时,在本次工资发放阶段,公司决定奖励带薪佣金雇员,把他们的基本工资提高10%。
设计提示:使用抽象类。


  1. #include <iostream>
  2. #include <string>

  3. using namespace std;

  4. class Salary{
  5. public :
  6.     virtual void calculate(void) = 0;
  7.     virtual void print_result(void) = 0;
  8.     virtual ~Salary(){};
  9. };

  10. class Date{
  11. private :

  12. public :
  13.     int year, month, day;
  14.     Date(int y, int m, int d) : year(y), month(m), day(d){};
  15.     bool isbirthday(void){ return month == 1;}
  16.     ~Date(){};
  17. };

  18. class SalariedEmployee : public Salary{
  19. private :
  20.     int salary = 4*1000;
  21.     string Name, Id;
  22.     Date *birthday;

  23. public :
  24.     SalariedEmployee(string pname, string pid){ Name = pname, Id = pid;}

  25.     void calculate(void){
  26.     cout << "请输入该周薪员工" << Name<<"的生日" << endl;
  27.     cout << "请输入出生年!" << endl;
  28.     cin >> birthday->year;
  29.     cout << "请输入出生月!" << endl;
  30.     cin >> birthday->month;
  31.     cout << "请输入出生日!" << endl;
  32.     cin >> birthday->day;
  33.     if(birthday->isbirthday()) salary += 100;}
  34.     void print_result(void){
  35.         cout << "该员工为周薪员工\n姓名为:" << Name << endl;
  36.         cout << "工号为:" << Id << endl;
  37.         if(birthday->isbirthday())
  38.         cout << "本月为员工生日!奖励100元!" << endl;
  39.         cout << "工资为(固定周薪为1000元):"  << salary << endl;
  40.         }
  41.     ~SalariedEmployee(){delete this;}
  42. };

  43. class HourlyEmployee : public Salary{
  44. private :
  45.     int salary = 0;
  46.     string Name, Id;
  47.     Date *birthday;
  48.     int hour;

  49. public :
  50.     HourlyEmployee(string pname, string pid)
  51.     {
  52.     Name = pname, Id = pid;
  53.     cout << "请输入该时薪员工" << Name<<"的生日" << endl;
  54.     cout << "请输入出生年!" << endl;
  55.     cin >> birthday->year;
  56.     cout << "请输入出生月!" << endl;
  57.     cin >> birthday->month;
  58.     cout << "请输入出生日!" << endl;
  59.     cin >> birthday->day;
  60.     }

  61.     void calculate(void){
  62.         cout << "请输入该时薪员工" << Name<< "工作时长:";
  63.         cin >> hour;

  64.         if(hour <= 40)
  65.         {
  66.         salary = hour * 20;
  67.         }
  68.         else
  69.         {
  70.         salary = 800 + (hour - 40) * 30;
  71.         }
  72.         if(birthday->isbirthday()) salary += 100;
  73.     }
  74.     void print_result(void){
  75.     cout << "该员工为时薪员工\n姓名为:" << Name << endl;
  76.     cout << "工号为:" << Id << endl;
  77.     if(birthday->isbirthday())
  78.         cout << "本月为员工生日!奖励100元!" << endl;
  79.     cout << "工资为(基础时薪为20元):" << salary << endl;
  80.     }
  81.     ~HourlyEmployee(){};
  82. };

  83. class CommissionEmployee : public Salary{
  84. private :
  85.     int salary = 0;
  86.     string Name, Id;
  87.     Date *birthday;
  88.     int num;

  89. public :
  90.     CommissionEmployee(string pname, string pid)
  91.     {
  92.     Name = pname, Id = pid;
  93.     cout << "请输入该佣金员工" << Name<<"的生日" << endl;
  94.     cout << "请输入出生年!" << endl;
  95.     cin >> birthday->year;
  96.     cout << "请输入出生月!" << endl;
  97.     cin >> birthday->month;
  98.     cout << "请输入出生日!" << endl;
  99.     cin >> birthday->day;
  100.     }

  101.     void calculate(void){
  102.         cout << "请输入该佣金员工" << Name<<"销售数量:";
  103.         cin >> num;
  104.         salary = num * 5;
  105.        if(birthday->isbirthday()) salary += 100;
  106.     }
  107.     void print_result(void){
  108.     cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  109.     cout << "工号为:" << Id << endl;
  110.     if(birthday->isbirthday())
  111.         cout << "本月为员工生日!奖励100元!" << endl;
  112.     cout << "工资为(销售佣金为5元):" << salary << endl;
  113.     }
  114. };

  115. class BasePlusCommissionEmployee : public Salary{
  116. private :
  117.     float salary;
  118.     string Name, Id;
  119.     Date *birthday;
  120.     int num;

  121. public :
  122.     BasePlusCommissionEmployee(string pname, string pid)
  123.     {
  124.     Name = pname, Id = pid;
  125.     cout << "请输入该带底薪佣金员工" << Name<<"的生日" << endl;
  126.     cout << "请输入出生年!" << endl;
  127.     cin >> birthday->year;
  128.     cout << "请输入出生月!" << endl;
  129.     cin >> birthday->month;
  130.     cout << "请输入出生日!" << endl;
  131.     cin >> birthday->day;
  132.     }

  133.     void calculate(void){
  134.         cout << "请输入该带底薪佣金员工" << Name<<"销售数量:";
  135.         cin >> num;
  136.         salary = num * 3 + 1100;
  137.        if(birthday->isbirthday()) salary += 100;
  138.     }
  139.     void print_result(void){
  140.     cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  141.     cout << "工号为:" << Id << endl;
  142.     if(birthday->isbirthday())
  143.         cout << "本月为员工生日!奖励100元!" << endl;
  144.     cout << "工资为(底薪1100元(提高百分之十!),销售佣金为3元):" << salary << endl;
  145.     }
  146. };

  147. void fn(Salary &A)
  148. {
  149.     A.calculate();
  150.     A.print_result();
  151. }

  152. Salary& inputA(string name, string id)
  153. {
  154.     return *new SalariedEmployee(name, id);
  155. }

  156. Salary& inputB(string name, string id)
  157. {
  158.     return *new HourlyEmployee(name, id);
  159. }

  160. Salary& inputC(string name, string id)
  161. {
  162.     return *new CommissionEmployee(name, id);
  163. }

  164. Salary& inputD(string name, string id)
  165. {
  166.     return *new BasePlusCommissionEmployee(name, id);
  167. }

  168. int main()
  169. {
  170.     cout << "当前为一月份!" << endl;
  171.     Salary& A = inputA("张三", "001");fn(A);
  172.     Salary& B = inputB("李四", "002");fn(B);
  173.     Salary& C = inputC("王五", "003");fn(C);
  174.     Salary& D = inputD("赵六", "004");fn(D);





  175.     return 0;
  176. }
复制代码
最佳答案
2021-6-5 22:14:11
因为我不知道应该输入些什么,对于这些输入,输出什么才是正确的
只把代码改成这样
  1. #include <iostream>
  2. #include <string>

  3. using namespace std;

  4. class Salary{
  5. public :
  6.     virtual void calculate(void) = 0;
  7.     virtual void print_result(void) = 0;
  8.     virtual ~Salary(){};
  9. };

  10. class Date{
  11. private :

  12. public :
  13.     int year, month, day;


  14.     Date(): year(0), month(0), day(0) {}



  15.     Date(int y, int m, int d) : year(y), month(m), day(d){};
  16.     bool isbirthday(void){ return month == 1;}
  17.     ~Date(){};
  18. };

  19. class SalariedEmployee : public Salary{
  20. private :
  21.     int salary = 4*1000;
  22.     string Name, Id;
  23.     Date *birthday;

  24. public :
  25.     SalariedEmployee(string pname, string pid){ Name = pname, Id = pid;}

  26.     void calculate(void){
  27.         cout << "请输入该周薪员工" << Name<<"的生日" << endl;
  28.         cout << "请输入出生年!" << endl;



  29.         this->birthday = new Date;




  30.         cin >> birthday->year;
  31.         cout << "请输入出生月!" << endl;
  32.         cin >> birthday->month;
  33.         cout << "请输入出生日!" << endl;
  34.         cin >> birthday->day;
  35.         if(birthday->isbirthday()) salary += 100;}
  36.     void print_result(void){
  37.         cout << "该员工为周薪员工\n姓名为:" << Name << endl;
  38.         cout << "工号为:" << Id << endl;
  39.         if(birthday->isbirthday())
  40.             cout << "本月为员工生日!奖励100元!" << endl;
  41.         cout << "工资为(固定周薪为1000元):"  << salary << endl;
  42.     }
  43.     //~SalariedEmployee(){delete this;}
  44.     ~SalariedEmployee(){delete this->birthday;}
  45. };

  46. class HourlyEmployee : public Salary{
  47. private :
  48.     int salary = 0;
  49.     string Name, Id;
  50.     Date *birthday;
  51.     int hour;

  52. public :
  53.     HourlyEmployee(string pname, string pid)
  54.     {
  55.         Name = pname, Id = pid;
  56.         cout << "请输入该时薪员工" << Name<<"的生日" << endl;
  57.         cout << "请输入出生年!" << endl;



  58.         this->birthday = new Date;



  59.         cin >> birthday->year;
  60.         cout << "请输入出生月!" << endl;
  61.         cin >> birthday->month;
  62.         cout << "请输入出生日!" << endl;
  63.         cin >> birthday->day;
  64.     }

  65.     void calculate(void){
  66.         cout << "请输入该时薪员工" << Name<< "工作时长:";
  67.         cin >> hour;

  68.         if(hour <= 40)
  69.         {
  70.             salary = hour * 20;
  71.         }
  72.         else
  73.         {
  74.             salary = 800 + (hour - 40) * 30;
  75.         }
  76.         if(birthday->isbirthday()) salary += 100;
  77.     }
  78.     void print_result(void){
  79.         cout << "该员工为时薪员工\n姓名为:" << Name << endl;
  80.         cout << "工号为:" << Id << endl;
  81.         if(birthday->isbirthday())
  82.             cout << "本月为员工生日!奖励100元!" << endl;
  83.         cout << "工资为(基础时薪为20元):" << salary << endl;
  84.     }
  85.     ~HourlyEmployee(){delete this->birthday;};
  86. };

  87. class CommissionEmployee : public Salary{
  88. private :
  89.     int salary = 0;
  90.     string Name, Id;
  91.     Date *birthday;
  92.     int num;

  93. public :
  94.     CommissionEmployee(string pname, string pid)
  95.     {
  96.         Name = pname, Id = pid;
  97.         cout << "请输入该佣金员工" << Name<<"的生日" << endl;
  98.         cout << "请输入出生年!" << endl;


  99.         this->birthday = new Date;


  100.         cin >> birthday->year;
  101.         cout << "请输入出生月!" << endl;
  102.         cin >> birthday->month;
  103.         cout << "请输入出生日!" << endl;
  104.         cin >> birthday->day;
  105.     }

  106.     void calculate(void){
  107.         cout << "请输入该佣金员工" << Name<<"销售数量:";
  108.         cin >> num;
  109.         salary = num * 5;
  110.         if(birthday->isbirthday()) salary += 100;
  111.     }
  112.     void print_result(void){
  113.         cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  114.         cout << "工号为:" << Id << endl;
  115.         if(birthday->isbirthday())
  116.             cout << "本月为员工生日!奖励100元!" << endl;
  117.         cout << "工资为(销售佣金为5元):" << salary << endl;
  118.     }

  119.     ~CommissionEmployee() {delete this->birthday;}
  120. };

  121. class BasePlusCommissionEmployee : public Salary{
  122. private :
  123.     float salary;
  124.     string Name, Id;
  125.     Date *birthday;
  126.     int num;

  127. public :
  128.     BasePlusCommissionEmployee(string pname, string pid)
  129.     {
  130.         Name = pname, Id = pid;
  131.         cout << "请输入该带底薪佣金员工" << Name<<"的生日" << endl;
  132.         cout << "请输入出生年!" << endl;


  133.         this->birthday = new Date;


  134.         cin >> birthday->year;
  135.         cout << "请输入出生月!" << endl;
  136.         cin >> birthday->month;
  137.         cout << "请输入出生日!" << endl;
  138.         cin >> birthday->day;
  139.     }

  140.     void calculate(void){
  141.         cout << "请输入该带底薪佣金员工" << Name<<"销售数量:";
  142.         cin >> num;
  143.         salary = num * 3 + 1100;
  144.         if(birthday->isbirthday()) salary += 100;
  145.     }
  146.     void print_result(void){
  147.         cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  148.         cout << "工号为:" << Id << endl;
  149.         if(birthday->isbirthday())
  150.             cout << "本月为员工生日!奖励100元!" << endl;
  151.         cout << "工资为(底薪1100元(提高百分之十!),销售佣金为3元):" << salary << endl;
  152.     }

  153.     ~BasePlusCommissionEmployee() {delete this->birthday;}
  154. };

  155. void fn(Salary &A)
  156. {
  157.     A.calculate();
  158.     A.print_result();
  159. }

  160. Salary& inputA(string name, string id)
  161. {
  162.     return *new SalariedEmployee(name, id);
  163. }

  164. Salary& inputB(string name, string id)
  165. {
  166.     return *new HourlyEmployee(name, id);
  167. }

  168. Salary& inputC(string name, string id)
  169. {
  170.     return *new CommissionEmployee(name, id);
  171. }

  172. Salary& inputD(string name, string id)
  173. {
  174.     return *new BasePlusCommissionEmployee(name, id);
  175. }

  176. int main()
  177. {
  178.     cout << "当前为一月份!" << endl;
  179.     Salary& A = inputA("张三", "001");fn(A);
  180.     Salary& B = inputB("李四", "002");fn(B);
  181.     Salary& C = inputC("王五", "003");fn(C);
  182.     Salary& D = inputD("赵六", "004");fn(D);
  183.     delete &A; delete &B; delete &C; delete &D;
  184.     return 0;
  185. }
复制代码

最佳答案

查看完整内容

因为我不知道应该输入些什么,对于这些输入,输出什么才是正确的 只把代码改成这样
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:14:11 | 显示全部楼层    本楼为最佳答案   
因为我不知道应该输入些什么,对于这些输入,输出什么才是正确的
只把代码改成这样
  1. #include <iostream>
  2. #include <string>

  3. using namespace std;

  4. class Salary{
  5. public :
  6.     virtual void calculate(void) = 0;
  7.     virtual void print_result(void) = 0;
  8.     virtual ~Salary(){};
  9. };

  10. class Date{
  11. private :

  12. public :
  13.     int year, month, day;


  14.     Date(): year(0), month(0), day(0) {}



  15.     Date(int y, int m, int d) : year(y), month(m), day(d){};
  16.     bool isbirthday(void){ return month == 1;}
  17.     ~Date(){};
  18. };

  19. class SalariedEmployee : public Salary{
  20. private :
  21.     int salary = 4*1000;
  22.     string Name, Id;
  23.     Date *birthday;

  24. public :
  25.     SalariedEmployee(string pname, string pid){ Name = pname, Id = pid;}

  26.     void calculate(void){
  27.         cout << "请输入该周薪员工" << Name<<"的生日" << endl;
  28.         cout << "请输入出生年!" << endl;



  29.         this->birthday = new Date;




  30.         cin >> birthday->year;
  31.         cout << "请输入出生月!" << endl;
  32.         cin >> birthday->month;
  33.         cout << "请输入出生日!" << endl;
  34.         cin >> birthday->day;
  35.         if(birthday->isbirthday()) salary += 100;}
  36.     void print_result(void){
  37.         cout << "该员工为周薪员工\n姓名为:" << Name << endl;
  38.         cout << "工号为:" << Id << endl;
  39.         if(birthday->isbirthday())
  40.             cout << "本月为员工生日!奖励100元!" << endl;
  41.         cout << "工资为(固定周薪为1000元):"  << salary << endl;
  42.     }
  43.     //~SalariedEmployee(){delete this;}
  44.     ~SalariedEmployee(){delete this->birthday;}
  45. };

  46. class HourlyEmployee : public Salary{
  47. private :
  48.     int salary = 0;
  49.     string Name, Id;
  50.     Date *birthday;
  51.     int hour;

  52. public :
  53.     HourlyEmployee(string pname, string pid)
  54.     {
  55.         Name = pname, Id = pid;
  56.         cout << "请输入该时薪员工" << Name<<"的生日" << endl;
  57.         cout << "请输入出生年!" << endl;



  58.         this->birthday = new Date;



  59.         cin >> birthday->year;
  60.         cout << "请输入出生月!" << endl;
  61.         cin >> birthday->month;
  62.         cout << "请输入出生日!" << endl;
  63.         cin >> birthday->day;
  64.     }

  65.     void calculate(void){
  66.         cout << "请输入该时薪员工" << Name<< "工作时长:";
  67.         cin >> hour;

  68.         if(hour <= 40)
  69.         {
  70.             salary = hour * 20;
  71.         }
  72.         else
  73.         {
  74.             salary = 800 + (hour - 40) * 30;
  75.         }
  76.         if(birthday->isbirthday()) salary += 100;
  77.     }
  78.     void print_result(void){
  79.         cout << "该员工为时薪员工\n姓名为:" << Name << endl;
  80.         cout << "工号为:" << Id << endl;
  81.         if(birthday->isbirthday())
  82.             cout << "本月为员工生日!奖励100元!" << endl;
  83.         cout << "工资为(基础时薪为20元):" << salary << endl;
  84.     }
  85.     ~HourlyEmployee(){delete this->birthday;};
  86. };

  87. class CommissionEmployee : public Salary{
  88. private :
  89.     int salary = 0;
  90.     string Name, Id;
  91.     Date *birthday;
  92.     int num;

  93. public :
  94.     CommissionEmployee(string pname, string pid)
  95.     {
  96.         Name = pname, Id = pid;
  97.         cout << "请输入该佣金员工" << Name<<"的生日" << endl;
  98.         cout << "请输入出生年!" << endl;


  99.         this->birthday = new Date;


  100.         cin >> birthday->year;
  101.         cout << "请输入出生月!" << endl;
  102.         cin >> birthday->month;
  103.         cout << "请输入出生日!" << endl;
  104.         cin >> birthday->day;
  105.     }

  106.     void calculate(void){
  107.         cout << "请输入该佣金员工" << Name<<"销售数量:";
  108.         cin >> num;
  109.         salary = num * 5;
  110.         if(birthday->isbirthday()) salary += 100;
  111.     }
  112.     void print_result(void){
  113.         cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  114.         cout << "工号为:" << Id << endl;
  115.         if(birthday->isbirthday())
  116.             cout << "本月为员工生日!奖励100元!" << endl;
  117.         cout << "工资为(销售佣金为5元):" << salary << endl;
  118.     }

  119.     ~CommissionEmployee() {delete this->birthday;}
  120. };

  121. class BasePlusCommissionEmployee : public Salary{
  122. private :
  123.     float salary;
  124.     string Name, Id;
  125.     Date *birthday;
  126.     int num;

  127. public :
  128.     BasePlusCommissionEmployee(string pname, string pid)
  129.     {
  130.         Name = pname, Id = pid;
  131.         cout << "请输入该带底薪佣金员工" << Name<<"的生日" << endl;
  132.         cout << "请输入出生年!" << endl;


  133.         this->birthday = new Date;


  134.         cin >> birthday->year;
  135.         cout << "请输入出生月!" << endl;
  136.         cin >> birthday->month;
  137.         cout << "请输入出生日!" << endl;
  138.         cin >> birthday->day;
  139.     }

  140.     void calculate(void){
  141.         cout << "请输入该带底薪佣金员工" << Name<<"销售数量:";
  142.         cin >> num;
  143.         salary = num * 3 + 1100;
  144.         if(birthday->isbirthday()) salary += 100;
  145.     }
  146.     void print_result(void){
  147.         cout << "该员工为佣金员工\n姓名为:" << Name << endl;
  148.         cout << "工号为:" << Id << endl;
  149.         if(birthday->isbirthday())
  150.             cout << "本月为员工生日!奖励100元!" << endl;
  151.         cout << "工资为(底薪1100元(提高百分之十!),销售佣金为3元):" << salary << endl;
  152.     }

  153.     ~BasePlusCommissionEmployee() {delete this->birthday;}
  154. };

  155. void fn(Salary &A)
  156. {
  157.     A.calculate();
  158.     A.print_result();
  159. }

  160. Salary& inputA(string name, string id)
  161. {
  162.     return *new SalariedEmployee(name, id);
  163. }

  164. Salary& inputB(string name, string id)
  165. {
  166.     return *new HourlyEmployee(name, id);
  167. }

  168. Salary& inputC(string name, string id)
  169. {
  170.     return *new CommissionEmployee(name, id);
  171. }

  172. Salary& inputD(string name, string id)
  173. {
  174.     return *new BasePlusCommissionEmployee(name, id);
  175. }

  176. int main()
  177. {
  178.     cout << "当前为一月份!" << endl;
  179.     Salary& A = inputA("张三", "001");fn(A);
  180.     Salary& B = inputB("李四", "002");fn(B);
  181.     Salary& C = inputC("王五", "003");fn(C);
  182.     Salary& D = inputD("赵六", "004");fn(D);
  183.     delete &A; delete &B; delete &C; delete &D;
  184.     return 0;
  185. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:24:29 | 显示全部楼层
问题1:你输入了什么?
问题2:对于这个输入,你期望输出什么才正确?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-6-5 22:30:48 | 显示全部楼层
人造人 发表于 2021-6-5 22:24
问题1:你输入了什么?
问题2:对于这个输入,你期望输出什么才正确?

1.我打算依次输入四个员工的生日,然后还有干的活算工资。
2.输出的话就是派生类里面那个print_result函数都输出出来(员工的个人信息和工资)
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:33:57 | 显示全部楼层
eventide 发表于 2021-6-5 22:30
1.我打算依次输入四个员工的生日,然后还有干的活算工资。
2.输出的话就是派生类里面那个print_result函 ...

我要具体的输入,在这里我应该输入什么
  1. $ ./main
  2. 当前为一月份!
  3. 请输入该周薪员工张三的生日
  4. 请输入出生年!

复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-6-5 22:36:58 | 显示全部楼层
人造人 发表于 2021-6-5 22:33
我要具体的输入,在这里我应该输入什么

2000 1 1依次输
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:41:57 | 显示全部楼层

问题1:你输入了什么?
问题2:对于这个输入,你期望输出什么才正确?

你不把输入说完整,怎么说输出?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:45:58 | 显示全部楼层
你不说输入和输出,我没法调试
上面的代码只是通过眼睛盯着代码看,看出的问题,并没有使用gdb进行调试,因为我不知道应该输入什么,对于这些输入,输出什么才正确
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-6-5 22:48:47 | 显示全部楼层
代码现在对了,大佬你能说下大概是什么问题吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 22:53:34 | 显示全部楼层
eventide 发表于 2021-6-5 22:48
代码现在对了,大佬你能说下大概是什么问题吗?

这样就可以了?我还没有用gdb调试呢
问题很明显的在代码中
我修改过的地方要么有注释,要么空了很多行
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-6-5 22:59:44 | 显示全部楼层
是Date类初始化的问题吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-6-5 23:00:48 | 显示全部楼层
eventide 发表于 2021-6-5 22:59
是Date类初始化的问题吗?

当然不止这一个问题
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-4 07:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表