E two classes called Traveler and Pager without default constructors, but with constructors that take an argument of type string which they simply copy to an internal string variable. For each class, write the correct copy-constructor and assignment operator. Now inherit a class BusinessTraveler from Traveler and give it a member object of type Pager. Write the correct default constructor, a constructor that takes a string argument, a copy-constructor, and an assignment operator 2. This exercise creates the design pattern called proxy. Start with a base class Subject and give it three functions: f(),g(), and h(). Now inherit a class Proxy and two classes Implementation and Implementation2 from Subject. Proxy should contain a pointer to a Subject, and all the member functions for Proxy should just turn around and make the same calls through the Subject pointer The Proxy constructor takes a pointer to a Subject that is installed in the Proxy(usually by the constructor). In main( ),create two different Proxy objects that use the two different implementations. Now modify Proxy so that you can dynamically change implementations 这个练习生成被称为 Proxy的设计模型。从基类 Subject开始并给出三个函数f)、g( 和h()现在从 Subject派生类 Proxy和另外两个类 Implementaation和 Implementation2 Proxy 应包含指向 Subject的指针,并且所有成员函数应当转换且通过 Subkect指针做出相同的调 用。 Proxy构造函数带有一个指向 Subject的指针参数(通常通过构造函数)。在main()中, 生成两个不同的 Proxy对象,使用两个不同的工具,现在修改 Proxy以致于你能动态改变工
Exercises5 1、Create two classes called Traveler and Pager without default constructors, but with constructors that take an argument of type string, which they simply copy to an internal string variable. For each class, write the correct copy-constructor and assignment operator. Now inherit a class BusinessTraveler from Traveler and give it a member object of type Pager. Write the correct default constructor, a constructor that takes a string argument, a copy-constructor, and an assignment operator. 2、This exercise creates the design pattern called proxy. Start with a base class Subject and give it three functions: f( ), g( ), and h( ). Now inherit a class Proxy and two classes Implementation1 and Implementation2 from Subject. Proxy should contain a pointer to a Subject, and all the member functions for Proxy should just turn around and make the same calls through the Subject pointer. The Proxy constructor takes a pointer to a Subject that is installed in the Proxy (usually by the constructor). In main( ), create two different Proxy objects that use the two different implementations. Now modify Proxy so that you can dynamically change implementations. 一、这个练习生成被称为 Proxy 的设计模型。从基类 Subject 开始并给出三个函数 f( )、g( ) 和h( )。现在从Subject派生类Proxy和另外两个类Implementaation1和Implementation2。Proxy 应包含指向 Subject 的指针,并且所有成员函数应当转换且通过 Subkect 指针做出相同的调 用。Proxy 构造函数带有一个指向 Subject 的指针参数(通常通过构造函数)。在 main( )中, 生成两个不同的 Proxy 对象,使用两个不同的工具,现在修改 Proxy 以致于你能动态改变工 具