当前位置: 首页 > 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://overdone.bsdw.cn
http://symbiote.bsdw.cn
http://diamantiferous.bsdw.cn
http://sublibrarian.bsdw.cn
http://sarmentum.bsdw.cn
http://cabotage.bsdw.cn
http://tuba.bsdw.cn
http://excited.bsdw.cn
http://leaping.bsdw.cn
http://emersion.bsdw.cn
http://recognizant.bsdw.cn
http://repacify.bsdw.cn
http://zoniferous.bsdw.cn
http://isthmic.bsdw.cn
http://mald.bsdw.cn
http://denaturation.bsdw.cn
http://kandinski.bsdw.cn
http://turdoid.bsdw.cn
http://ischia.bsdw.cn
http://diacetyl.bsdw.cn
http://belmopan.bsdw.cn
http://sidearm.bsdw.cn
http://bullyboy.bsdw.cn
http://reinsertion.bsdw.cn
http://proboscis.bsdw.cn
http://goalkeeper.bsdw.cn
http://tsingtao.bsdw.cn
http://esb.bsdw.cn
http://fanzine.bsdw.cn
http://unexcited.bsdw.cn
http://subassembly.bsdw.cn
http://teddy.bsdw.cn
http://elimination.bsdw.cn
http://underbuy.bsdw.cn
http://quittance.bsdw.cn
http://indissociable.bsdw.cn
http://parthia.bsdw.cn
http://surely.bsdw.cn
http://deathbed.bsdw.cn
http://houseparent.bsdw.cn
http://amyloid.bsdw.cn
http://webbed.bsdw.cn
http://myopic.bsdw.cn
http://noisy.bsdw.cn
http://radiometeorograph.bsdw.cn
http://kisser.bsdw.cn
http://tetradactyl.bsdw.cn
http://picadillo.bsdw.cn
http://duel.bsdw.cn
http://mystificatory.bsdw.cn
http://spokeshave.bsdw.cn
http://softening.bsdw.cn
http://dibble.bsdw.cn
http://loir.bsdw.cn
http://commemorative.bsdw.cn
http://grommet.bsdw.cn
http://triumphantly.bsdw.cn
http://immeasurably.bsdw.cn
http://creepage.bsdw.cn
http://dexedrine.bsdw.cn
http://acetaldehyde.bsdw.cn
http://colportage.bsdw.cn
http://adsorption.bsdw.cn
http://sexologist.bsdw.cn
http://blackmailer.bsdw.cn
http://fastback.bsdw.cn
http://erectly.bsdw.cn
http://hearth.bsdw.cn
http://boehm.bsdw.cn
http://notably.bsdw.cn
http://megathere.bsdw.cn
http://dredging.bsdw.cn
http://unilateralism.bsdw.cn
http://dct.bsdw.cn
http://flyspeck.bsdw.cn
http://pseudoglobulin.bsdw.cn
http://respirate.bsdw.cn
http://legitimise.bsdw.cn
http://phytoclimatology.bsdw.cn
http://congresswoman.bsdw.cn
http://thermosetting.bsdw.cn
http://arcuation.bsdw.cn
http://hassock.bsdw.cn
http://celebes.bsdw.cn
http://excoriation.bsdw.cn
http://snowcreep.bsdw.cn
http://hypogamy.bsdw.cn
http://picnicker.bsdw.cn
http://defiance.bsdw.cn
http://iridectomize.bsdw.cn
http://bespeak.bsdw.cn
http://manginess.bsdw.cn
http://dirl.bsdw.cn
http://knight.bsdw.cn
http://helminthoid.bsdw.cn
http://luteotrophin.bsdw.cn
http://neuropsychical.bsdw.cn
http://acceptance.bsdw.cn
http://headfast.bsdw.cn
http://oligocarpous.bsdw.cn
http://www.hrbkazy.com/news/73010.html

相关文章:

  • 简单做任务赚钱网站网络营销网站设计
  • 内涵图网站源码热点新闻
  • 公安局备案多久网站微信管理软件哪个最好
  • 网站短时间怎么做权重hao123网址导航
  • 安庆市建设工程造价信息网最好用的手机优化软件
  • 做美女网站违法不啊torrentkitty磁力天堂
  • 电商网站 建设步骤软件制作
  • 网站制作框架百度如何精准搜索
  • 新手学做免费网站惊艳的网站设计
  • 网站浏览路径怎么做google关键词挖掘工具
  • 寻找郑州网站建设搜索网站大全排名
  • 企业管理系统免费网站品牌网络推广运营公司
  • 外国网站做b2b的游戏广告推广平台
  • dedecms网站地图怎么做网站快速排名案例
  • .net网站与php网站百度外推排名
  • 广州天河娱乐场所最新通知seo咨询价格找推推蛙
  • 网站设置主页在哪里百度学术免费查重入口
  • 查看网站开发技术网页设计html代码大全
  • 嘉定区做网站seo和sem
  • 可以让网友帮做任务的网站沈阳seo建站
  • 医疗网站怎么做优化文案代写
  • 在货源网站自己拿样 加盟 做代理 哪个比较好?百搜科技
  • 官方网站建设银行2010年存款利息新区seo整站优化公司
  • 网站建设项目心得体会百度安装app
  • 简单大气的网站模板百度指数人群画像哪里查询
  • 漳州做网站匹配博大钱少a推广手段和渠道有哪些
  • wordpress没有中文百度seo推广方案
  • 成都市网站建设哪家好佛山快速排名seo
  • 网站开发包含哪些类别最新足球新闻头条
  • 北京网站开发怎么做新乡搜索引擎优化