Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Expert C++

You're reading from   Expert C++ Become a proficient programmer by learning coding best practices with C++17 and C++20's latest features

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781838552657
Length 606 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Vardan Grigoryan Vardan Grigoryan
Author Profile Icon Vardan Grigoryan
Vardan Grigoryan
Shunguang Wu Shunguang Wu
Author Profile Icon Shunguang Wu
Shunguang Wu
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Section 1: Under the Hood of C++ Programming
2. Introduction to Building C++ Applications FREE CHAPTER 3. Low-Level Programming with C++ 4. Details of Object-Oriented Programming 5. Understanding and Designing Templates 6. Memory Management and Smart Pointers 7. Section 2: Designing Robust and Efficient Applications
8. Digging into Data Structures and Algorithms in STL 9. Functional Programming 10. Concurrency and Multithreading 11. Designing Concurrent Data Structures 12. Designing World-Ready Applications 13. Designing a Strategy Game Using Design Patterns 14. Networking and Security 15. Debugging and Testing 16. Graphical User Interface with Qt 17. Section 3: C++ in the AI World
18. Using C++ in Machine Learning Tasks 19. Implementing a Dialog-Based Search Engine 20. Assessments 21. Other Books You May Enjoy

Introducing Linking

The compiler outputs an object file for each compilation unit. In the previous example, we had three .cpp files and the compiler produced three object files. The task of the linker is to combine these object files together into a single object file. Combining files together results in relative address changes; for example, if the linker puts the rect.o file after main.o, the starting address of rect.o becomes 0x04 instead of the previous value of 0x00:

code: 
0x00 main
0x01 Rect r;
0x02 _Rect_init_(&r, 3.1, 4.05);
0x03 printf("%d\n", _Rect_get_area(&r));
0x04 _Rect_init_
0x05 side1_ = s1
0x06 side2_ = s2
0x07 return
0x08 _Rect_get_area_
0x09 register = side1_
0x0A reg_multiply side2_
0x0B return
information (symbol table):
main: 0x00
_Rect_init_: 0x04
printf: ????
_Rect_get_area_: 0x08

_Rect_init_: 0x04
_Rect_get_area_...
You have been reading a chapter from
Expert C++
Published in: Apr 2020
Publisher: Packt
ISBN-13: 9781838552657
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime