《C++ Primer Plus》(第6版)第13章编程练习
创始人
2025-05-31 08:26:13
0次

《C++ Primer Plus》(第6版)第13章编程练习

  • 《C++ Primer Plus》(第6版)第13章编程练习
    • 1. Cd类
    • 2. 使用动态内存分配重做练习1
    • 3. baseDMA、lacksDMA、hasDMA类
    • 4. Port类和VintagePort类

《C++ Primer Plus》(第6版)第13章编程练习

1. Cd类

以下面的类声明为基础:

class Cd {                    //represents a CD disk
private:char performers[50];char label[20];int selections;          //number of selectionsdouble playtime;        //playing time in minute
public:Cd(char* s1, char* s2, int n, double x);Cd(const Cd& d);Cd();~Cd();void Report() const; //reports all CD dataCd& operator=(const Cd& d);
};

派生出一个Classic类,并添加一组char成员,用于存储指出CD中主要作品的字符串。修改上述声明,使基类的搜有函数都是虚的。如果上述定义声明的某个方法并不需要,则请删除它。使用下面的程序测试您的产品:

#include
using namespace std;
#include"classic.h"void Bravo(const Cd& disk);int main()
{Cd c1("beatles", "Capitol", 14, 35.5);Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);Cd* pcd = &c1;cout << "Using object directly:\n";c1.Report(); //use Cd methodc2.Report(); //use Classic methodcout << "Using type cd *pointer to objects:\n";pcd->Report(); //use Cd method for cd objectpcd = &c2;pcd->Report(); //use Classic method for classic objectcout << "Calling a function with a Cd reference argument:\n";Bravo(c1);Bravo(c2);cout << "Testing assignment: ";Classic copy;copy = c2;copy.Report();return 0;
}void Bravo(const Cd& disk)
{disk.Report();
}

代码:

cd.h:

#ifndef CD_H_
#define CD_H_class Cd
{ // represents a CD disk
private:char performers[50];char label[20];int selections;  // number of selectionsdouble playtime; // playing time in minutepublic:Cd(char *s1, char *s2, int n, double x);Cd(const Cd &d);Cd();virtual ~Cd();virtual void Report() const; // reports all CD datavirtual Cd &operator=(const Cd &d);
};#endif

cd.cpp:

#include "cd.h"
#include 
#include Cd::Cd(char *s1, char *s2, int n, double x)
{strncpy(performers, s1, 49);performers[49] = '\0';strncpy(label, s2, 19);label[19] = '\0';selections = n;playtime = x;
}
Cd::Cd(const Cd &d)
{strncpy(performers, d.performers, 49);performers[49] = '\0';strncpy(label, d.label, 19);label[19] = '\0';selections = d.selections;playtime = d.playtime;
}
Cd::Cd()
{performers[0] = '\0';label[0] = '\0';selections = 0;playtime = 0.0;
}
Cd::~Cd()
{
}
void Cd::Report() const
{using std::cout;using std::endl;cout << "Information:\n";cout << "Performers: " << performers << endl;cout << "Label: " << label << endl;cout << "Selections: " << selections << endl;cout << "Playtime: " << playtime << endl;
}
Cd &Cd::operator=(const Cd &d)
{if (this == &d)return *this;strncpy(performers, d.performers, 49);performers[49] = '\0';strncpy(label, d.label, 19);label[19] = '\0';selections = d.selections;playtime = d.playtime;return *this;
}

classic.h:

#ifndef CLASSIC_H_
#define CLASSIC_H_#include "cd.h"class Classic : public Cd
{
private:char majorWorks[50];public:Classic(char *m, char *s1, char *s2, int n, double x);Classic(char *m, const Cd &cd);Classic();virtual ~Classic();virtual void Report() const;virtual Classic &operator=(const Classic &c);
};#endif

classic.cpp:

#include "classic.h"
#include 
#include Classic::Classic(char *m, char *s1, char *s2, int n, double x) : Cd(s1, s2, n, x)
{strncpy(majorWorks, m, 49);majorWorks[49] = '\0';
}
Classic::Classic(char *m, const Cd &cd) : Cd(cd)
{strncpy(majorWorks, m, 49);majorWorks[49] = '\0';
}
Classic::Classic() : Cd()
{majorWorks[0] = '\0';
}
Classic::~Classic()
{
}
void Classic::Report() const
{using std::cout;using std::endl;Cd::Report();cout << "Major works: " << majorWorks << endl;
}
Classic &Classic::operator=(const Classic &c)
{if (this == &c)return *this;Cd::operator=(c);strncpy(majorWorks, c.majorWorks, 49);majorWorks[49] = '\0';return *this;
}

main.cpp:

#include 
using namespace std;
#include "classic.h"void Bravo(const Cd &disk);int main()
{Cd c1("beatles", "Capitol", 14, 35.5);Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);Cd *pcd = &c1;cout << "Using object directly:\n";c1.Report(); // use Cd methodc2.Report(); // use Classic methodcout << "Using type cd *pointer to objects:\n";pcd->Report(); // use Cd method for cd objectpcd = &c2;pcd->Report(); // use Classic method for classic objectcout << "Calling a function with a Cd reference argument:\n";Bravo(c1);Bravo(c2);cout << "Testing assignment: ";Classic copy;copy = c2;copy.Report();system("pause");return 0;
}void Bravo(const Cd &disk)
{disk.Report();
}

运行结果:

Microsoft Windows [版本 10.0.19044.2728]
(c) Microsoft Corporation。保留所有权利。C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.1>g++ cd.cpp classic.cpp main.cpp -o main
main.cpp: In function 'int main()':
main.cpp:9:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]Cd c1("beatles", "Capitol", 14, 35.5);^
main.cpp:9:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);^
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.1>main
Using object directly:
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Using type cd *pointer to objects:
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Calling a function with a Cd reference argument:  
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Testing assignment: Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
请按任意键继续. . .C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.1>

2. 使用动态内存分配重做练习1

完成练习1,但让两个类使用动态内存分配而不是长度固定的数组来记录字符串。

代码:

cd.h

#ifndef CD_H_
#define CD_H_class Cd
{ // represents a CD disk
private:char *performers;char *label;int selections;  // number of selectionsdouble playtime; // playing time in minutepublic:Cd(char *s1, char *s2, int n, double x);Cd(const Cd &d);Cd();virtual ~Cd();virtual void Report() const; // reports all CD datavirtual Cd &operator=(const Cd &d);
};#endif

cd.cpp:

#include "cd.h"
#include 
#include 
using std::strcpy;
using std::strlen;Cd::Cd(char *s1, char *s2, int n, double x)
{performers = new char[strlen(s1) + 1];strcpy(performers, s1);label = new char[strlen(s2) + 1];strcpy(label, s2);selections = n;playtime = x;
}
Cd::Cd(const Cd &d)
{performers = new char[strlen(d.performers) + 1];strcpy(performers, d.performers);label = new char[strlen(d.label) + 1];strcpy(label, d.label);selections = d.selections;playtime = d.playtime;
}
Cd::Cd()
{performers = new char[1];strcpy(performers, "\0");label = new char[1];strcpy(label, "\0");selections = 0;playtime = 0.0;
}
Cd::~Cd()
{delete[] performers;delete[] label;
}
void Cd::Report() const
{using std::cout;using std::endl;cout << "Information:\n";cout << "Performers: " << performers << endl;cout << "Label: " << label << endl;cout << "Selections: " << selections << endl;cout << "Playtime: " << playtime << endl;
}
Cd &Cd::operator=(const Cd &d)
{if (this == &d)return *this;delete[] performers;delete[] label;performers = new char[strlen(d.performers) + 1];strcpy(performers, d.performers);label = new char[strlen(d.label) + 1];strcpy(label, d.label);selections = d.selections;playtime = d.playtime;return *this;
}

classic.h:

#ifndef CLASSIC_H_
#define CLASSIC_H_#include "cd.h"class Classic : public Cd
{
private:char *majorWorks;public:Classic(char *m, char *s1, char *s2, int n, double x);Classic(char *m, const Cd &cd);Classic();virtual ~Classic();virtual void Report() const;virtual Classic &operator=(const Classic &c);
};#endif

classic.cpp:

#include "classic.h"
#include 
#include 
using std::strcpy;
using std::strlen;Classic::Classic(char *m, char *s1, char *s2, int n, double x) : Cd(s1, s2, n, x)
{majorWorks = new char[strlen(m) + 1];strcpy(majorWorks, m);
}
Classic::Classic(char *m, const Cd &cd) : Cd(cd)
{majorWorks = new char[strlen(m) + 1];strcpy(majorWorks, m);
}
Classic::Classic() : Cd()
{majorWorks = new char[1];strcpy(majorWorks, "\0");
}
Classic::~Classic()
{delete[] majorWorks;
}
void Classic::Report() const
{using std::cout;using std::endl;Cd::Report();cout << "Major works: " << majorWorks << endl;
}
Classic &Classic::operator=(const Classic &c)
{if (this == &c)return *this;Cd::operator=(c);majorWorks = new char[strlen(c.majorWorks) + 1];strcpy(majorWorks, c.majorWorks);return *this;
}

main.cpp与练习1的main.cpp相同。

运行结果:

C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.2>g++ cd.cpp classic.cpp main.cpp -o main
main.cpp: In function 'int main()':
main.cpp:9:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]Cd c1("beatles", "Capitol", 14, 35.5);^
main.cpp:9:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);^
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
main.cpp:10:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.2>main
Using object directly:
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Using type cd *pointer to objects:
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Calling a function with a Cd reference argument:
Information:
Performers: beatles
Label: Capitol
Selections: 14
Playtime: 35.5
Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
Testing assignment: Information:
Performers: Alfred Brendel
Label: Philips
Selections: 2
Playtime: 57.17
Major works: Piano Sonata in B flat, Fantasia in C
请按任意键继续. . .C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.2>

3. baseDMA、lacksDMA、hasDMA类

修改baseDMA-lacksDMA-hasDMA类层次,让三个类都从一个ABC派生而来,然后使用与程序清单13.10相似的程序对结果进行测试。也就是说,它应使用ABC指针数组,并让用户决定要创建的对象类型。在类定义中添加virtual View()方法以处理数据显示。

代码:

dma.h:

#ifndef DMA_H_
#define DMA_H_#include class ABC
{
public:ABC(){};~ABC(){};virtual void View() = 0;
};class baseDMA : public ABC
{
private:char *label;int rating;public:baseDMA(const char *l = "null", int r = 0);baseDMA(const baseDMA &rs);virtual ~baseDMA();baseDMA &operator=(const baseDMA &rs);friend std::ostream &operator<<(std::ostream &os, const baseDMA &rs);virtual void View();
};class lacksDMA : public baseDMA
{
private:enum{COL_LEN = 40};char color[COL_LEN];public:lacksDMA(const char *c = "blank", const char *l = "null", int r = 0);lacksDMA(const char *c, const baseDMA &rs);friend std::ostream &operator<<(std::ostream &os, const lacksDMA &rs);virtual void View();
};
class hasDMA : public baseDMA
{
private:char *style;public:hasDMA(const char *s = "none", const char *l = "null", int r = 0);hasDMA(const char *s, const baseDMA &rs);hasDMA(const hasDMA &hs);~hasDMA();hasDMA &operator=(const hasDMA &hs);friend std::ostream &operator<<(std::ostream &os, const hasDMA &hs);virtual void View();
};#endif

dma.cpp:

#include "dma.h"
#include 
#include 
using std::cout;
using std::endl;
using std::strcpy;
using std::strlen;
using std::strncpy;// baseDMA methods
baseDMA::baseDMA(const char *l, int r)
{label = new char[strlen(l) + 1];strcpy(label, l);rating = r;
}
baseDMA::baseDMA(const baseDMA &rs)
{label = new char[strlen(rs.label) + 1];strcpy(label, rs.label);rating = rs.rating;
}
baseDMA::~baseDMA()
{delete[] label;
}
baseDMA &baseDMA::operator=(const baseDMA &rs)
{if (this == &rs)return *this;delete[] label;label = new char[strlen(rs.label) + 1];strcpy(label, rs.label);rating = rs.rating;return *this;
}
std::ostream &operator<<(std::ostream &os, const baseDMA &rs)
{os << "Label: " << rs.label << endl;os << "Rating: " << rs.rating << endl;return os;
}
void baseDMA::View()
{cout << "Label: " << label << endl;cout << "Rating: " << rating << endl;
}// lacksDMA methods
lacksDMA::lacksDMA(const char *c, const char *l, int r) : baseDMA(l, r)
{strncpy(color, c, 39);color[39] = '\0';
}
lacksDMA::lacksDMA(const char *c, const baseDMA &rs) : baseDMA(rs)
{strncpy(color, c, COL_LEN - 1);color[COL_LEN - 1] = '\0';
}
std::ostream &operator<<(std::ostream &os, const lacksDMA &ls)
{os << (const baseDMA &)ls;os << "Color: " << ls.color << endl;return os;
}
void lacksDMA::View()
{baseDMA::View();cout << "Color: " << color << endl;
}// hasDMA methods
hasDMA::hasDMA(const char *s, const char *l, int r) : baseDMA(l, r)
{style = new char[strlen(s) + 1];strcpy(style, s);
}
hasDMA::hasDMA(const char *s, const baseDMA &rs) : baseDMA(rs)
{style = new char[strlen(s) + 1];strcpy(style, s);
}
hasDMA::hasDMA(const hasDMA &hs) : baseDMA(hs)
{style = new char[strlen(hs.style) + 1];strcpy(style, hs.style);
}
hasDMA::~hasDMA()
{delete[] style;
}
hasDMA &hasDMA::operator=(const hasDMA &hs)
{if (this == &hs)return *this;baseDMA::operator=(hs);delete[] style;style = new char[strlen(hs.style) + 1];strcpy(style, hs.style);return *this;
}
std::ostream &operator<<(std::ostream &os, const hasDMA &hs)
{os << (const baseDMA &)hs;os << "Style: " << hs.style << endl;return os;
}
void hasDMA::View()
{baseDMA::View();cout << "Style: " << style << endl;
}

main.cpp:

#include "dma.h"
#include 
#include 
using namespace std;int main()
{int n;cout << "How many DMAs do you have? ";cin >> n;ABC *p_dma[n];char *t_label = new char[50];int t_rating;int kind;for (int i = 0; i < n; i++){cout << "Enter label: ";cin.getline(t_label, 50);cout << "Enter rating: ";cin >> t_rating;cout << "Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: ";while (cin >> kind && kind != 1 && kind != 2 && kind != 3)cout << "Enter either 1 or 2 or 3: ";cin.ignore();switch (kind){case 1:p_dma[i] = new baseDMA(t_label, t_rating);break;case 2:char t_color[40];cout << "Enter color: ";cin.getline(t_color, 40);p_dma[i] = new lacksDMA(t_color, t_label, t_rating);break;case 3:char *t_style = new char[20];cout << "Enter style: ";cin.getline(t_style, 20);p_dma[i] = new hasDMA(t_style, t_label, t_rating);break;}while (cin.get() != '\n')continue;}cout << endl;for (int i = 0; i < n; i++){p_dma[i]->View();cout << endl;}for (int i = 0; i < n; i++){delete p_dma[i];}cout << "Done.\n"<< endl;system("pause");return 0;
}

运行结果:

Microsoft Windows [版本 10.0.19044.2728]
(c) Microsoft Corporation。保留所有权利。C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.3>g++ dma.cpp main.cpp -o mainC:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.3>main
Enter label: Portabelly
Enter rating: 8
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 1Enter label: Blimpo
Enter rating: 4
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 2
Enter color: redEnter label: Buffalo Keys
Enter rating: 5
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 3
Enter style: MercatorEnter label: lable1
Enter rating: 10
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 1Enter label: lable2
Enter rating: 3
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 1Enter label: lable3
Enter rating: 1
Enter 1 for baseDMA or 2 for lacksDMA or 3 for hasDMA: 9
Enter either 1 or 2 or 3: 1Label: Portabelly
Rating: 8Label: Blimpo
Rating: 4
Color: redLabel: Buffalo Keys
Rating: 5
Style: MercatorLabel: lable1
Rating: 10Label: lable2
Rating: 3Label: lable3
Rating: 1Done.请按任意键继续. . .C:\Users\81228\Documents\Program\VScode C++ Program\chapter13\13.3>

4. Port类和VintagePort类

Benevolent Order of Programmers用来维护瓶装葡萄酒箱。为描述它,BOP Portmaster设置了一个Port类,并声明如下:

#include 
using namespace std;
class Port
{
private:char *brand;char style[20]; // i.e., tawny, ruby, vintageint bottles;public:Port(const char *br = "none", const char *st = "none", int b = 0);Port(const Port &p); // copy constructorvirtual ~Port() { delete[] brand; }Port &operator=(const Port &p);Port &operator+=(int b); // add b to bottlesPort &operator-=(int b); // subtracts b from bottles , if availableint BottleCount() const { return bottles; }virtual void Show() const;friend ostream &operator<<(ostream &os, const Port &p);
};

show()方法按下面的格式显示信息:

Brand : Gallo
Kind : tawny
Bottles : 20

operator<<()函数按下面的格式显示信息(末尾没有换行符):

Gallo, tawny, 20

PortMaster完成了Port类的方法定义后派生了VintagePort类,然后被解职——因为不小心将一瓶45度Cockburn泼到了正在准备烤肉调料的人身上,VintagePort类如下显示:

class VintagePort : public Port //style necessarily = "vintage"
{
private:char* nickname; //i.e. , "The Noble" or "Old Velvet", etc.int year; //vintage year
public:VintagePort();VintagePort(const char* br, const char* st, int b, const char* nn, int y);VintagePort(const VintagePort& vp);~VintagePort() { delete[] nickname; }VintagePort& operator = (const VintagePort& vp);void show() const;friend ostream& operator <<(ostream& os, const VintagePort& vp);
};

您被制定指定负责完成VintagePort。
a.第一个任务是重新创建Port方法定义,因为前任被开除时销毁了方法定义。
b.第二个任务是解释为什么有的方法重新定义了,而有些没有重新定义。
c.第三个任务解释为何没有将operator = () 和operator << ()声明为虚的。
d.第四个任务是提供VintagePort中各个方法的定义。

答:

a.第一个任务是重新创建Port方法定义,因为前任被开除时销毁了方法定义。

#include "port.h"
#include 
#include 
using namespace std;Port::Port(const char *br, const char *st, int b)
{brand = new char[strlen(br) + 1];strcpy(brand, br);strcpy(style, st);bottles = b;
}
Port::Port(const Port &p) // copy constructor
{brand = new char[strlen(p.brand) + 1];strcpy(brand, p.brand);strcpy(style, p.style);bottles = p.bottles;
}
Port &Port::operator=(const Port &p)
{if (this == &p)return *this;delete[] brand;brand = new char[strlen(p.brand) + 1];strcpy(brand, p.brand);strcpy(style, p.style);bottles = p.bottles;return *this;
}
Port &Port::operator+=(int b) // add b to bottles
{bottles += b;return *this;
}
Port &Port::operator-=(int b) // subtracts b from bottles , if available
{bottles -= b;return *this;
}
void Port::Show() const
{cout << "Brand: " << brand << endl;cout << "Kind: " << style << endl;cout << "Bottles: " << bottles << endl;
}
ostream &operator<<(ostream &os, const Port &p)
{os << p.brand << "," << p.style << "," << p.bottles;return os;
}

b.第二个任务是解释为什么有的方法重新定义了,而有些没有重新定义。

当派生类成员函数需要处理派生类独有的成员变量时,需要重新定义方法,如果不需要处理派生类独有的成员变量,直接调用基类的方法即可。

c.第三个任务解释为何没有将operator = () 和operator << ()声明为虚的。

a).如果要在派生类中重新定义基类的方法,则将它设置为虚方法。但是基类的operator = () 和派生类的operator = () 形参不一样,根本不是一个类方法,不存在重新定义的问题,因从也不必声明为虚的。
b).operator<<()函数是友元函数,友元函数不能是虚函数,因为友元不是类成员,而只有类成员才能是虚函数。

d.第四个任务是提供VintagePort中各个方法的定义。

#include "VintagePort.h"
#include 
#include 
using namespace std;VintagePort::VintagePort() : Port()
{
}
VintagePort::VintagePort(const char *br, const char *st, int b, const char *nn, int y) : Port(br, st, b)
{nickname = new char[strlen(nn) + 1];strcpy(nickname, nn);int year = y;
}
VintagePort::VintagePort(const VintagePort &vp) : Port(vp)
{nickname = new char[strlen(vp.nickname) + 1];strcpy(nickname, vp.nickname);int year = vp.year;
}
VintagePort &VintagePort::operator=(const VintagePort &vp)
{if (this == &vp)return *this;Port::operator=(vp);delete[] nickname;nickname = new char[strlen(vp.nickname) + 1];strcpy(nickname, vp.nickname);strcpy(nickname, vp.nickname);year = vp.year;return *this;
}
void VintagePort::show() const
{Port::Show();cout << "Nick Name: " << nickname << endl;cout << "Year: " << year << endl;
}
ostream &operator<<(ostream &os, const VintagePort &vp)
{os << (const Port &)vp;os << vp.nickname << "," << vp.year;return os;
}

相关内容

热门资讯

在大吉订购APP订购交易亏损被...   近期,不少投资者反映在“大吉订购App”上投资白银、铂金等商品遭遇严重亏损。该平台宣称提供现货订...
铂银壹号APP商品订购交易亏损...   许多中小投资者误以为网上的“商品现货订购”是合规合法的理财渠道,殊不知这背后隐藏着巨大的合规风险...
兴鑫淘金APP贵金属订购交易亏...   白银、贵金属或其他商品类投资,除国家批准的正规期货交易场所及持牌期货公司外,市面上大量第三方交易...
铂银掘金APP无资质的违规平台...   铂银掘金等平台的投资者,往往是被“注册送现金”“充值返现券”“首单免亏”等广告话术吸引,进而下载...
八方淘金APP订购交易不合规,...   “八方淘金APP”“铂银掘金APP”“铂银壹号APP”等软件被指以“现货订购”为名,实际采用高杠...
在指尖订购APP订购商品亏损被...   指尖订购APP这类平台,表面是“订购交易”,实则是披着电商外衣的非法期货陷阱。绝大多数投资者被蒙...
在犀贝易购APP做商品订购交易...   市面上打着“现货投资”“贵金属交易”旗号的APP并不少,但真正合规、受监管的平台并不多。犀贝易购...
易达淘金APP虚假商品订购交易...   易达淘金APP存在严重的虚假宣传与违规交易行为。该平台打着“商品订购”的旗号,实则通过不合规的交...
大浪淘金APP白银订购亏损被骗...   大浪淘金APP最隐蔽的套路,在于其完全封闭的内盘交易系统。表面上,它宣称与国际贵金属市场接轨;实...
一品好购APP上订购白银出现亏...   一品好购APP原名“一品订购”,运营方为上海宝智未来信息技术有限公司。近期不少投资者反映在该平台...
九州订购APP贵金属订购投资骗...   九州订购APP正通过抖.音、快手、今日头条等平台大量投放投资广告,用“5元起投”“充值返现”“0...
坚锅淘金APP交易软件并不正规...   当前,市面上大量所谓的“现货商城订购”交易软件,早已偏离了正常的实物商品买卖,演变为高杠杆、高手...
斗金订购APP贵金属期货交易骗...   斗金订购APP的投资者往往被铺天盖地的广告宣传所诱导——注册即送现金、充值返现券等看似诱人的福利...
警惕!云启购APP违规经营,披...   "5元起投、充值返现、稳赚不赔"——这些诱人的广告语背后,可能是一个精心设计的金融陷阱。  近期...
量子淘金APP贵金属投资不合规...   "4元起投""充值返券""月入过万"——这些极具诱惑力的广告语在短视频平台、社交软件上铺天盖地。...
鑫汇智投APP贵金属商品订购骗...   鑫汇智投APP非法期货投资骗局,受害者在投资过程中根本不懂交易,也不去研究和验证这个平台是否正规...
矅光智策APP平台违规经营非法...   矅光智策APP对外宣称是“商城订购”“现货交易”,但查询其经营范围,并未显示具备开展现货期货交易...
黄金珠宝怎么选?内侧刻字都代表... 潮新闻客户端 记者 马焱 通讯员 任倩影 9月8日下午,“云游杭州 乐购金秋”——“浙城·浙放心”活...
原创 冰... 最近全球国债市场正在上演魔幻一幕: 美债、日债、欧债遭遇猛烈抛售,收益率冲到几十年新高,美国财政部都...
日韩股市开盘表现分化 上证报中国证券网讯 9月9日,日韩股市开盘表现分化,韩国综合指数开盘上涨0.26%,报6972.87...