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

西安建筑网站建设2023最近的新闻大事10条

西安建筑网站建设,2023最近的新闻大事10条,网站内容建设运维服务,上海营销型网站seo大家好,这里是国中之林! ❥前些天发现了一个巨牛的人工智能学习网站&#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/307538/

相关文章:

  • 淄博市 网站建设报价郑州seo外包阿亮
  • 网络服务商是指什么网站优化排名工具
  • 网站优化的分析比较好的品牌策划公司有哪些
  • 国外比较好的资源网站电商运营推广是做什么的
  • 佛山房地产网站建设seo实战培训王乃用
  • 如何做可以赚钱的网站关键词如何快速排名
  • 深圳品牌做网站公司有哪些百度app推广
  • 重庆建设行业信息网站搜狗登录入口
  • 同仁行业网站建设报价北京做的好的seo公司
  • 陕西自助建站做网站郑州外语网站建站优化
  • 小型企业网站系统cilimao磁力猫最新版地址
  • 铁岭网站建设移动网站广东网站seo
  • 网站模板插件sem和seo
  • 用wordpress制作网站模板沈阳seo
  • 优化一个网站多少钱宜昌网站seo
  • 刚做的网站怎么才能搜索到枸橼酸西地那非片功效效及作用
  • 罗湖区网站公司专业模板建站
  • 哪有备案好的网站国产系统2345
  • 网站开发怎么让别人看到最新营销模式有哪些
  • ssm网站开发源码百度推广多少钱一个月
  • 手游门户网站建设appstore关键词优化
  • 齐河网站开发seo服务内容
  • 北京微信网站建设费用想卖产品怎么推广宣传
  • 网站上线的步骤厦门网站推广公司哪家好
  • 网站做app的软件有哪些百度一下你就知道下载
  • 界面设计的重要性百度seo关键词排名推荐
  • 股票做T网站直播营销
  • 北京手机网站建设公司排名技术优化seo
  • wordpress可爱的主题seo优化教程
  • 自己可以申请网站做外卖吗网站描述和关键词怎么写