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

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

头文件

cpp 复制代码
#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文件

cpp 复制代码
#include "boy.h"
#include "Girl.h"

#define SALARY_FACTOR 0.006

Boy::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;
	}
	
相关推荐
rit843249927 分钟前
基于MATLAB的模糊图像复原
开发语言·matlab
fie888932 分钟前
基于MATLAB的声呐图像特征提取与显示
开发语言·人工智能
_extraordinary_2 小时前
Java SpringMVC(二) --- 响应,综合性练习
java·开发语言
Larry_Yanan2 小时前
QML学习笔记(三十四)QML的GroupBox、RadioButton
c++·笔记·qt·学习·ui
@。1243 小时前
对于灰度发布(金丝雀发布)的了解
开发语言·前端
程序员老舅3 小时前
干货|腾讯 Linux C/C++ 后端开发岗面试
linux·c语言·c++·编程·大厂面试题
程序员Aries3 小时前
自定义网络协议与序列化/反序列化
linux·网络·c++·网络协议·程序人生
Pafey3 小时前
MFC中一个类的成员变量值自动被篡改:多重继承带来的问题
c++·mfc
hsjkdhs3 小时前
C++之多层继承、多源继承、菱形继承
开发语言·c++·算法
Full Stack Developme4 小时前
Python Redis 教程
开发语言·redis·python