当前位置: 首页 > news >正文

【25.3】C++智能交友系统

仿照上篇文章,编写boy类,代码如下

头文件

#pragma once
#include <string>using namespace std;class Girl;
class Boy
{
public:Boy();Boy(int age, string name, int salary);~Boy();int getAge() const;string getName() const;int getSalary() const;bool satisfied(const Girl& girl) const;string description() const;
private:int age;string name;int salary;//薪资
};

cpp文件

#include "boy.h"
#include "Girl.h"#define SALARY_FACTOR 0.006Boy::Boy()
{age = 0;name = "";salary = 0;
}Boy::Boy(int age, string name, int salary)
{this->age = age;this->name = name;this->salary = salary;
}Boy::~Boy()
{
}int Boy::getAge() const
{return age;
}string Boy::getName() const
{return name;
}int Boy::getSalary() const
{return salary;
}string Boy::description() const
{stringstream ret;ret << name << "-男-年龄-" << age << "-薪资-" << salary;return string();
}bool Boy::satisfied(const Girl& girl) const
{if(girl.getStyle()>=salary*SALARY_FACTOR){return true;}else {return false;}


http://www.mrgr.cn/news/27029.html

相关文章:

  • 【C++知识扫盲】-----初识迭代器
  • 蔚来充换电站数字化运维系统案例分享
  • Linux环境
  • [Linux入门]---使用exec函数实现简易shell
  • Python基础语法(3)上
  • MySQL 表的增删改查
  • 多模态学习
  • 概述03 A/B test
  • 从关键新闻和最新技术看AI行业发展(第三十一期2024.8.26-9.8) |【WeThinkIn老实人报】
  • Linux——进程状态
  • Linux内核编译并移植至ARM平台
  • 跨平台互斥体封装
  • 数据结构:单链表
  • 前端必知必会-响应式网页设计Viewport和GridView
  • 家庭理财管理系统
  • 【极限、数学】 NOIP 2018 提高组初赛试题 第 7 题详解(线段长度期望)
  • 【代码随想录训练营第42期 Day58打卡 - 图论Part8 - 拓扑排序
  • 【免费资料推荐】数据资产管理实践白皮书(6.0版)
  • 每天五分钟玩转深度学习PyTorch:模型参数优化器torch.optim
  • 智能工厂的设计软件 之 语言设计