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

德阳建设机械网站个人网站设计

德阳建设机械网站,个人网站设计,软件技术就业前景分析,网站店铺vr场景可以做吗大家好,这里是国中之林! ❥前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。有兴趣的可以点点进去看看← 问题: 解答: main.cpp #include <iostream> #include "wine.h" …

大家好,这里是国中之林!
❥前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站。有兴趣的可以点点进去看看←

问题:

这里是引用
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

解答:
main.cpp

#include <iostream>
#include "wine.h"
using namespace std;int main()
{cout << "Enter name of wine:";char lab[50];cin.getline(lab, 50);cout << "Enter number of years:";int yrs;cin >> yrs;Wine holding(lab, yrs);holding.GetBottles();holding.show();const int YRS = 3;int y[YRS] = { 1993,1995,1998 };int b[YRS] = { 48,60,72 };Wine more("Gushing Grape Red", YRS, y, b);more.show();cout << "Total bottles for " << more.Label() << ":;" << more.sum() << endl;cout << "Bye!" << endl;return 0;
}

wine.h

#include <iostream>
#include <string>
#include <valarray>using namespace std;template <class T1, class T2> class Pair;
typedef valarray<int> ArrayInt;
typedef Pair<ArrayInt, ArrayInt> PairArray;template <class T1, class T2>
class Pair
{
private:T1 a;T2 b;
public:T1& first();T2& second();T1 first()const { return a; }T2 second()const { return b; }Pair(const T1& aval, const T2& bval) :a(aval), b(bval) {}Pair() {}
};class Wine
{
private:string label;PairArray info;int year;
public:Wine(const char* l, int y, const int yr[], const int bot[]);Wine(const char* l, int y);void GetBottles();const string& Label()const;int sum()const;void show();
};

wine.cpp

#include "wine.h"template<class T1, class T2>
T1& Pair<T1, T2>::first()
{return a;
}template<class T1, class T2>
T2& Pair<T1, T2>::second()
{return b;
}Wine::Wine(const char* l, int y, const int yr[], const int bot[]):info(ArrayInt(yr,y),ArrayInt(bot,y))
{this->label = l;this->year = y;		
}
Wine::Wine(const char* l, int y):info(ArrayInt(0,0),ArrayInt(0,0))
{this->label = l;this->year = y;
}
void Wine::GetBottles()
{cout << "Enter " << label << " data for" << year << "year:" << endl;info.first().resize(year);info.second().resize(year);for (int i = 0; i < year; i++){cout << "Enter year: ";cin >> info.first()[i];cout << "Enter bottles for that year: ";cin >> info.second()[i];}
}
const string& Wine::Label()const
{return label;
}
int Wine::sum()const
{return info.second().sum();
}
void Wine::show()
{cout << "Wine: " << label << endl;cout << " Year Bottles" << endl;for (int i = 0; i < year; i++){cout << " " << info.first()[i] << "   " << info.second()[i] << endl;}
}

运行结果:
在这里插入图片描述

考查点:

  • 模版类
  • 类型重定义typedef
  • 组合
  • valarray模版类

注意:

  • 构造函数用的初始化列表进行初始化,且用了valarray构造函数
    在这里插入图片描述
  • valarray可重新指定数组大小
    在这里插入图片描述
  • valarray也可以计算数组总数
    在这里插入图片描述
  • 模版类一定要记得说明哦
    在这里插入图片描述

2024年9月9日19:49:55

http://www.hkea.cn/news/931903/

相关文章:

  • 网站建设首页怎样插入视频百度指数在线查询小程序
  • 青州网站制作哪家好aso优化哪家好
  • wordpress做网站优点郑州网站seo优化
  • 宝安做棋牌网站建设找哪家公司好湖南长沙疫情最新消息
  • 四川专业网站建设中国十大企业培训机构排名
  • 怎么切页面做网站灰色词首页排名接单
  • 网站右侧浮动广告代码百度推广代理公司广州
  • 固原建站公司旺道seo推广系统怎么收费
  • 适合做外链的网站海外广告联盟平台推广
  • 建筑模板规格型号郑州厉害的seo顾问
  • ppt做书模板下载网站有哪些内容国际婚恋网站排名
  • 上海网站建设内容更新网络营销策划目的
  • 重庆市建设信息网站关键词查询网
  • 做哪种网站流量大怎么打广告宣传自己的产品
  • 免费表白网站制作seo网络优化推广
  • 网站建设中可能升级中国科技新闻网
  • 网站制作内容文案网站如何快速被百度收录
  • 淘宝淘宝网页版登录入口免费seo公司
  • 竹溪县县建设局网站短视频营销
  • 好的网站有哪些搜索引擎seo是什么意思
  • 做音乐网站赚钱吗做小程序的公司
  • 坪地网站建设域名流量查询工具
  • 网站建设部署万能推广app
  • 网站的重要性怎么做个网站
  • 做网站的经验百度旗下有哪些app
  • 化工网站开发推广点击器
  • 怎么访问日本竹中建设网站外贸seo推广
  • 惠阳建设局网站引流推广接单
  • 北京通州网站建设公司如何建立公司网站网页
  • 网站换程序301seo优化按天扣费