-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.prototype.cpp
50 lines (47 loc) · 1.88 KB
/
4.prototype.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by Tianyi Zhang on 11/4/20.
//
#include "4.prototype.h"
void foo(Prototype prototype){
prototype.print();
prototype.clone().print();
}
int main(){
PrototypeFactory prototypeFactory;
std::cout<<"------Prototype Factory built, start cloning------"<<std::endl;
auto p1cloned = prototypeFactory.cloneSavedPrototype(Type::PROTOTYPE_1);
p1cloned.print();
prototypeFactory.cloneSavedPrototype(Type::PROTOTYPE_2).print();
return 0;
}
/*
LargeObject string constructor called
LargeObject copy constructor called
ConcretePrototype1 constructor called
Prototype template constructor is called
LargeObject move constructor called
ConcretePrototype1 move constructor called
PrototypeModel constructor is called
Prototype default constructor is called
Prototype operator = move assignment operator is called
ConcretePrototype2 constructor called
Prototype template constructor is called
ConcretePrototype2 copy constructor called
PrototypeModel constructor is called
Prototype default constructor is called
Prototype operator = move assignment operator is called
------Prototype Factory built, start cloning------
LargeObject copy constructor called
ConcretePrototype1 copy constructor called
Prototype template constructor is called
LargeObject move constructor called
ConcretePrototype1 move constructor called
PrototypeModel constructor is called
Prototype move constructor is called
Printing ConcretePrototype1: prototypeName : ConcretePrototype1, rarelyChangedField : this field contains info rarely changes for ConcretePrototype1!
ConcretePrototype2 copy constructor called
Prototype template constructor is called
ConcretePrototype2 copy constructor called
PrototypeModel constructor is called
Prototype move constructor is called
Printing ConcretePrototype2: prototypeName : ConcretePrototype2 , rarelyChangedField : this field contains info rarely changes for ConcretePrototype2!*/