// File: iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/sample.cc
// Function: main
int main()
{
	Quote basic("0-201-54848-8", 45);
	Bulk_quote bulk("0-201-82470-1", 45, 3, .15);

	// basic has type Quote; bulk has type Bulk_quote
	print_total(cout, basic, 20); // calls Quote version of net_price 
	print_total(cout, bulk, 20);  // calls Bulk_quote version of net_price 
	Quote base("0-201-82470-1", 50);
	Bulk_quote derived("0-201-82470-1", 50, 5, .19);
	cout << derived.net_price(20); // calls Bulk_quote::net_price
	cout << endl;

	base = derived;        // copies the Quote part of derived into base
	cout << base.net_price(20);    // calls Quote::net_price
	cout << endl;

	Quote &item = derived; // dynamic and static types of item differ
	cout << item.net_price(20);    // calls Bulk_quote::net_price

	item.isbn();           // isbn is not virtual, calls Bulk::isbn
	cout << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movl $0x0, -0x4(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x2110
movq -0x1c8(%rbp), %rdx
leaq 0xd70(%rip), %rsi       # 0x3050
leaq -0x58(%rbp), %rdi
callq 0x20e0
jmp 0x22eb
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movsd 0xd0d(%rip), %xmm0      # 0x3008
callq 0x2710
jmp 0x2302
leaq -0x58(%rbp), %rdi
callq 0x2060
leaq -0x59(%rbp), %rdi
callq 0x20d0
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x2110
movq -0x1d0(%rbp), %rdx
leaq 0xd29(%rip), %rsi       # 0x305e
leaq -0xd0(%rbp), %rdi
callq 0x20e0
jmp 0x2343
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movsd 0xcaf(%rip), %xmm0      # 0x3008
movl $0x3, %edx
movsd 0xcaa(%rip), %xmm1      # 0x3010
callq 0x2760
jmp 0x236d
leaq -0xd0(%rbp), %rdi
callq 0x2060
leaq -0xd1(%rbp), %rdi
callq 0x20d0
movq 0x2c4c(%rip), %rdi      # 0x4fd8
leaq -0x38(%rbp), %rsi
movl $0x14, %edx
callq 0x2a40
jmp 0x239c
movq 0x2c35(%rip), %rdi      # 0x4fd8
leaq -0xb0(%rbp), %rsi
movl $0x14, %edx
callq 0x2a40
jmp 0x23b6
leaq -0x129(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x2110
movq -0x1d8(%rbp), %rdx
leaq 0xc87(%rip), %rsi       # 0x305e
leaq -0x128(%rbp), %rdi
callq 0x20e0
jmp 0x23e5
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
movsd 0xc1d(%rip), %xmm0      # 0x3018
callq 0x2710
jmp 0x2402
leaq -0x128(%rbp), %rdi
callq 0x2060
leaq -0x129(%rbp), %rdi
callq 0x20d0
leaq -0x191(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x2110
movq -0x1e0(%rbp), %rdx
leaq 0xc23(%rip), %rsi       # 0x305e
leaq -0x190(%rbp), %rdi
callq 0x20e0
jmp 0x2449
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
movsd 0xbb9(%rip), %xmm0      # 0x3018
movl $0x5, %edx
movsd 0xbb4(%rip), %xmm1      # 0x3020
callq 0x2760
jmp 0x2473
leaq -0x190(%rbp), %rdi
callq 0x2060
leaq -0x191(%rbp), %rdi
callq 0x20d0
leaq -0x170(%rbp), %rdi
movl $0x14, %esi
callq 0x2b50
movsd %xmm0, -0x1e8(%rbp)
jmp 0x24a6
movsd -0x1e8(%rbp), %xmm0
movq 0x2b23(%rip), %rdi      # 0x4fd8
callq 0x2120
jmp 0x24bc
movq 0x2b15(%rip), %rdi      # 0x4fd8
movq 0x2afe(%rip), %rsi      # 0x4fc8
callq 0x20c0
jmp 0x24d1
leaq -0x108(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x27c0
jmp 0x24e6
leaq -0x108(%rbp), %rdi
movl $0x14, %esi
callq 0x2810
movsd %xmm0, -0x1f0(%rbp)
jmp 0x2501
movsd -0x1f0(%rbp), %xmm0
movq 0x2ac8(%rip), %rdi      # 0x4fd8
callq 0x2120
jmp 0x2517
movq 0x2aba(%rip), %rdi      # 0x4fd8
movq 0x2aa3(%rip), %rsi      # 0x4fc8
callq 0x20c0
jmp 0x252c
leaq -0x170(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movl $0x14, %esi
callq *%rax
movsd %xmm0, -0x1f8(%rbp)
jmp 0x2559
movsd -0x1f8(%rbp), %xmm0
movq 0x2a70(%rip), %rdi      # 0x4fd8
callq 0x2120
jmp 0x256f
movq -0x1a0(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x2850
jmp 0x2584
leaq -0x1c0(%rbp), %rdi
callq 0x2060
movq 0x2a41(%rip), %rdi      # 0x4fd8
movq 0x2a2a(%rip), %rsi      # 0x4fc8
callq 0x20c0
jmp 0x25a5
movl $0x0, -0x4(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x2880
leaq -0x108(%rbp), %rdi
callq 0x28a0
leaq -0xb0(%rbp), %rdi
callq 0x2880
leaq -0x38(%rbp), %rdi
callq 0x28a0
movl -0x4(%rbp), %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2608
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2060
leaq -0x59(%rbp), %rdi
callq 0x20d0
jmp 0x26ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x263c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x2060
leaq -0xd1(%rbp), %rdi
callq 0x20d0
jmp 0x26f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2684
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x2060
leaq -0x129(%rbp), %rdi
callq 0x20d0
jmp 0x26ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x2060
leaq -0x191(%rbp), %rdi
callq 0x20d0
jmp 0x26de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x2880
leaq -0x108(%rbp), %rdi
callq 0x28a0
leaq -0xb0(%rbp), %rdi
callq 0x2880
leaq -0x38(%rbp), %rdi
callq 0x28a0
movq -0x68(%rbp), %rdi
callq 0x2100
nopl (%rax,%rax)