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

免费影视网站建设怎么样推广自己的网址

免费影视网站建设,怎么样推广自己的网址,网站建设徐州百度网络网站,wordpress关键词工具文章目录练习7.31练习7.32练习7.33练习7.34练习7.35练习7.36练习7.37练习7.38练习7.29练习7.40练习7.31 定义一对类X 和Y,其中X 包含一个指向 Y 的指针,而Y 包含一个类型为 X 的对象。 class Y;class X{Y* y nullptr; };class Y{X x; };练习7.32 定义你…

文章目录

      • 练习7.31
      • 练习7.32
      • 练习7.33
      • 练习7.34
      • 练习7.35
      • 练习7.36
      • 练习7.37
      • 练习7.38
      • 练习7.29
      • 练习7.40

练习7.31

定义一对类X 和Y,其中X 包含一个指向 Y 的指针,而Y 包含一个类型为 X 的对象。

class Y;class X{Y* y = nullptr;	
};class Y{X x;
};

练习7.32

定义你自己的Screen 和 Window_mgr,其中clear是Window_mgr的成员,是Screen的友元。

#ifndef CP5_ex7_32_h
#define CP5_ex7_32_h#include <vector>
#include <iostream>
#include <string>class Screen;class Window_mgr
{
public:using ScreenIndex = std::vector<Screen>::size_type;inline void clear(ScreenIndex);private:std::vector<Screen> screens;
};class Screen
{friend void Window_mgr::clear(ScreenIndex);public:using pos = std::string::size_type;Screen() = default;Screen(pos ht, pos wd) :height(ht), width(wd), contents(ht*wd,' ') {}Screen(pos ht, pos wd, char c) :height(ht), width(wd), contents(ht*wd, c) {}char get() const { return contents[cursor]; }char get(pos r, pos c) const { return contents[r*width + c]; }inline Screen& move(pos r, pos c);inline Screen& set(char c);inline Screen& set(pos r, pos c, char ch);const Screen& display(std::ostream& os) const { do_display(os); return *this; }Screen& display(std::ostream& os) { do_display(os); return *this; }private:void do_display(std::ostream &os) const { os << contents; }private:pos cursor = 0;pos width = 0, height = 0;std::string contents;
};inline void Window_mgr::clear(ScreenIndex i)
{Screen& s = screens[i];s.contents = std::string(s.height*s.width,' ');
}inline Screen& Screen::move(pos r, pos c)
{cursor = r*width + c;return *this;
}inline Screen& Screen::set(char c)
{contents[cursor] = c;return *this;
}inline Screen& Screen::set(pos r, pos c, char ch)
{contents[r*width + c] = ch;return *this;
}#endif

练习7.33

如果我们给Screen 添加一个如下所示的size成员将发生什么情况?如果出现了问题,请尝试修改它。

pos Screen::size() const
{return height * width;
}

未定义标识符 pos。应该改为:

Screen::pos Screen::size() const
{return height * width;
}

练习7.34

如果我们把第256页Screen类的pos的typedef放在类的最后一行会发生什么情况?

dummy_fcn(pos height) 函数中会出现 未定义的标识符pos

类型名的定义通常出现在类的开始处,这样就能确保所有使用该类型的成员都出现在类名的定义之后。

练习7.35

解释下面代码的含义,说明其中的Type和initVal分别使用了哪个定义。如果代码存在错误,尝试修改它。

typedef string Type;
Type initVal(); 
class Exercise {
public:typedef double Type;Type setVal(Type);Type initVal(); 
private:int val;
};
Type Exercise::setVal(Type parm) { val = parm + initVal();     return val;
}

书上255页中说

然而在类中,如果成员使用了外层作用域中的某个名字,而该名字代表一种类型,则类不能在之后重新定义该名字。

因此重复定义 Type 是错误的行为。

  • 虽然重复定义类型名字是错误的行为,但是编译器并不为此负责。所以我们要人为地遵守一些原则,在这里有一些讨论。

练习7.36

下面的初始值是错误的,请找出问题所在并尝试修改它。

struct X {X (int i, int j): base(i), rem(base % j) {}int rem, base;
};

应该改为:

struct X {X (int i, int j): base(i), rem(base % j) {}int base, rem;
};

练习7.37

使用本节提供的Sales_data类,确定初始化下面的变量时分别使用了哪个构造函数,然后罗列出每个对象所有的数据成员的值。

Sales_data first_item(cin); // 使用 Sales_data(std::istream &is) ; 各成员值从输入流中读取
int main() {Sales_data next; // 使用默认构造函数  bookNo = "", cnt = 0, revenue = 0.0// 使用 Sales_data(std::string s = "");   bookNo = "9-999-99999-9", cnt = 0, revenue = 0.0Sales_data last("9-999-99999-9"); 
}

练习7.38

有些情况下我们希望提供cin作为接受istream& 参数的构造函数的默认实参,请声明这样的构造函数。

Sales_data(std::istream &is = std::cin) { read(is, *this); }

练习7.29

如果接受string 的构造函数和接受 istream& 的构造函数都使用默认实参,这种行为合法吗?如果不,为什么?

不合法。当你调用 Sales_data() 构造函数时,无法区分是哪个重载。

练习7.40

从下面的抽象概念中选择一个(或者你自己指定一个),思考这样的类需要哪些数据成员,提供一组合理的构造函数并阐明这样做的原因。

(a) Book
(b) Data
(c) Employee
(d) Vehicle
(e) Object
(f) Tree

(a) Book.

class Book 
{
public:Book(unsigned isbn, std::string const& name, std::string const& author, std::string const& pubdate):isbn_(isbn), name_(name), author_(author), pubdate_(pubdate){ }explicit Book(std::istream &in) { in >> isbn_ >> name_ >> author_ >> pubdate_;}private:unsigned isbn_;std::string name_;std::string author_;std::string pubdate_;
};
http://www.tj-hxxt.cn/news/97032.html

相关文章:

  • 医疗 企业 网站建设网页优化最为重要的内容是
  • 图片设计网站有哪些seo分析工具
  • jsp b2c网站建设想要导航推广网页怎么做
  • 上海国际建设总承包公司网站软文代写
  • 企业网站官网制作微营销推广方案
  • 门户网站建设意义360优化大师官网
  • 榆林公司做网站淘宝的前100个关键词排名
  • 国外校园网站建设百度推广页面投放
  • 标准网站建设可以直接进入的舆情网站
  • 大理公司网站建设中国市场营销网
  • 网站架设教程百度推广客户端怎么登陆
  • 青岛做网站的公司免费b站软件推广网站2023
  • php网站开发实例教程 源代码网站自动收录
  • 想学做网站需要学什么seo 论坛
  • 苏州模板网站专业设计邢台市seo服务
  • 网站开发的历史搜索引擎优化公司
  • 破解wordpress登录密码电子商务seo名词解释
  • 邵武市2017建设局网站网上怎么免费推广
  • wordpress商城视频教程开封seo公司
  • wordpress pdf检索优化软件
  • 建设网站建设网页制作0402高设计词win10最强优化软件
  • 东阳市网站建设制作石家庄邮电职业技术学院
  • 深圳有名的网站设计公司南昌seo网站管理
  • 仪征市建设发展有限公司网站百度搜索指数和资讯指数
  • 企业管理咨询与诊断优化营商环境条例全文
  • 做塑胶网站需要什么材料关键词优化排名的步骤
  • 泰兴市 建设安全监察网站seo1域名查询
  • 宁波设计网页公司seo链接优化建议
  • 网站开发遇到过哪些技术难点国际新闻头条最新消息
  • 自己做的网站申请软著夜夜草