title
How C++ Works

description
Twitter ► https://twitter.com/thecherno Instagram ► https://instagram.com/thecherno Patreon ► https://patreon.com/thecherno Series Playlist ► https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb How the C++ Compiler Works ► https://youtu.be/3tIqpEmWMLI How the C++ Linker Works ► https://youtu.be/H4s55GgAg0I BEST laptop for programming! ► http://geni.us/pakTES My FAVOURITE keyboard for programming! ► http://geni.us/zNhB FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq MAIN Camera ► http://geni.us/CYUQ MAIN Lens ► http://geni.us/ZM3CmG Microphone ► http://geni.us/wqO6g7K Slack ► https://slack.thecherno.com Stream ► http://www.twitch.tv/thecherno Website ► http://www.thecherno.com Facebook ► http://www.facebook.com/thecherno

detail
{'title': 'How C++ Works', 'heatmap': [{'end': 529.423, 'start': 486.28, 'weight': 0.704}, {'end': 600.692, 'start': 570.836, 'weight': 1}, {'end': 721.701, 'start': 707.475, 'weight': 0.733}, {'end': 794.716, 'start': 780.263, 'weight': 0.841}], 'summary': "'how c++ works' delves into c++ basics, syntax, compilation, linking processes, file management, and error resolution. it covers topics such as c++ operators, visual studio compilation, file separation, and resolving linker errors, providing a comprehensive understanding of c++ development.", 'chapters': [{'end': 162.285, 'segs': [{'end': 40.038, 'src': 'embed', 'start': 19.409, 'weight': 2, 'content': [{'end': 31.214, 'text': 'The basic workflow of writing a C++ program is you have a series of source files which you write actual text in and then you pass it through a compiler which compiles it into some kind of binary.', 'start': 19.409, 'duration': 11.805}, {'end': 35.596, 'text': 'Now that binary can be some sort of library or it can be an actual executable program.', 'start': 31.434, 'duration': 4.162}, {'end': 40.038, 'text': "Today we're going to talk specifically about executable programs or executable binaries.", 'start': 35.896, 'duration': 4.142}], 'summary': 'C++ program workflow: source files compiled into executable binaries.', 'duration': 20.629, 'max_score': 19.409, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os19409.jpg'}, {'end': 88.506, 'src': 'embed', 'start': 57.425, 'weight': 1, 'content': [{'end': 60.366, 'text': 'Anything that begins with a hash is a preprocessor statement.', 'start': 57.425, 'duration': 2.941}, {'end': 66.309, 'text': 'The first thing that a compiler does when it receives a source file is it preprocesses all of your preprocessor statements.', 'start': 60.486, 'duration': 5.823}, {'end': 70.671, 'text': "That's why they're called preprocessor statements, because they happen just before the actual compilation.", 'start': 66.569, 'duration': 4.102}, {'end': 73.193, 'text': "In this case, it's something called include.", 'start': 71.411, 'duration': 1.782}, {'end': 75.515, 'text': 'What include will do is find a file.', 'start': 73.333, 'duration': 2.182}, {'end': 78.417, 'text': "So in this case, we're looking for a file called iostream.", 'start': 76.035, 'duration': 2.382}, {'end': 83.121, 'text': 'Take all of the contents of that file and just paste it into this current file.', 'start': 78.737, 'duration': 4.384}, {'end': 88.506, 'text': "These files that you include are typically called header files, and we'll discuss them more in depth as the series goes on.", 'start': 83.361, 'duration': 5.145}], 'summary': 'Preprocessor statements preprocess source files, including header files like iostream.', 'duration': 31.081, 'max_score': 57.425, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os57425.jpg'}, {'end': 124.035, 'src': 'embed', 'start': 94.491, 'weight': 0, 'content': [{'end': 96.152, 'text': 'which lets us print stuff to our console.', 'start': 94.491, 'duration': 1.661}, {'end': 97.913, 'text': 'Next we have this main function.', 'start': 96.592, 'duration': 1.321}, {'end': 102.317, 'text': 'Now the main function is very important because every C++ program has something like this.', 'start': 97.954, 'duration': 4.363}, {'end': 104.359, 'text': 'The main function is called the entry point.', 'start': 102.617, 'duration': 1.742}, {'end': 106.14, 'text': "It's the entry point for our application.", 'start': 104.439, 'duration': 1.701}, {'end': 111.785, 'text': 'That means that when we run our application, our computer starts executing code that begins in this function.', 'start': 106.581, 'duration': 5.204}, {'end': 116.409, 'text': 'As the program is running, our computer will execute the lines of code that we type in order.', 'start': 112.125, 'duration': 4.284}, {'end': 120.252, 'text': 'Of course, there are certain things that can break or change the order of execution,', 'start': 116.629, 'duration': 3.623}, {'end': 124.035, 'text': 'and those are primarily called control flow statements or calls to other functions.', 'start': 120.252, 'duration': 3.783}], 'summary': 'The main function in c++ is the entry point for the program, allowing the computer to execute code in order and handle control flow statements or calls to other functions.', 'duration': 29.544, 'max_score': 94.491, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os94491.jpg'}], 'start': 0.362, 'title': 'C++ basics: workflow and program execution', 'summary': 'Explains the basic workflow of writing a c++ program, including the process of going from a source file to an executable binary, the role of preprocessor statements, the main function as the entry point for the application, and the order of code execution.', 'chapters': [{'end': 162.285, 'start': 0.362, 'title': 'C++ basics: workflow and program execution', 'summary': 'Explains the basic workflow of writing a c++ program, including the process of going from a source file to an executable binary, the role of preprocessor statements, the main function as the entry point for the application, and the order of code execution.', 'duration': 161.923, 'highlights': ['The main function is called the entry point for C++ programs, and it dictates the order of code execution.', 'Preprocessor statements, such as include, are processed before actual compilation and are used to include contents from header files like iostream.', 'The process involves passing source files through a compiler to produce an executable binary program, with the main function being a critical element.']}], 'duration': 161.923, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os362.jpg', 'highlights': ['The main function is called the entry point for C++ programs, and it dictates the order of code execution.', 'Preprocessor statements, such as include, are processed before actual compilation and are used to include contents from header files like iostream.', 'The process involves passing source files through a compiler to produce an executable binary program, with the main function being a critical element.']}, {'end': 492.701, 'segs': [{'end': 218.741, 'src': 'embed', 'start': 162.605, 'weight': 0, 'content': [{'end': 168.752, 'text': "This kind of syntax might look strange for someone who's new to C++, and it is a little bit unfortunate that it's actually written this way,", 'start': 162.605, 'duration': 6.147}, {'end': 171.075, 'text': "because it doesn't make too much sense when you first look at it.", 'start': 168.752, 'duration': 2.323}, {'end': 177.942, 'text': 'But basically these left angular brackets, which look kind of like a bit shift left operator, are actually just an overloaded operator.', 'start': 171.275, 'duration': 6.667}, {'end': 180.886, 'text': 'So you need to think of them as a function.', 'start': 178.343, 'duration': 2.543}, {'end': 183.507, 'text': "Now I know they look like an operator, but here's the thing.", 'start': 181.286, 'duration': 2.221}, {'end': 185.668, 'text': 'Operators are just functions.', 'start': 184.047, 'duration': 1.621}, {'end': 193.491, 'text': 'So in this case, this would actually be the same thing as if it was something like cout.print and then hello world is our parameter.', 'start': 186.068, 'duration': 7.423}, {'end': 196.692, 'text': 'And then maybe we would follow it on along with another print.', 'start': 193.871, 'duration': 2.821}, {'end': 200.336, 'text': "That's all it is.", 'start': 199.696, 'duration': 0.64}, {'end': 202.537, 'text': 'You have to think of these operators as functions.', 'start': 200.596, 'duration': 1.941}, {'end': 205.358, 'text': 'And if you think of them that way, then this makes a little bit more sense.', 'start': 202.557, 'duration': 2.801}, {'end': 213.56, 'text': "So what we're actually doing here is we're pushing this hello world string into this cout, which basically causes it to get printed to the console.", 'start': 205.838, 'duration': 7.722}, {'end': 215.36, 'text': "And then we're pushing an end line.", 'start': 213.92, 'duration': 1.44}, {'end': 218.741, 'text': 'This end line basically just tells our console to advance to the next line.', 'start': 215.64, 'duration': 3.101}], 'summary': 'In c++, left angular brackets are overloaded operators, functioning like functions. they push strings to cout for console printing.', 'duration': 56.136, 'max_score': 162.605, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os162605.jpg'}, {'end': 288.841, 'src': 'embed', 'start': 255.919, 'weight': 7, 'content': [{'end': 257.82, 'text': 'First, we have this include IO stream.', 'start': 255.919, 'duration': 1.901}, {'end': 260.122, 'text': 'This is something called a preprocessor statement.', 'start': 257.86, 'duration': 2.262}, {'end': 264.686, 'text': 'So this preprocessor statement gets evaluated before we compile the file.', 'start': 260.482, 'duration': 4.204}, {'end': 270.05, 'text': 'In this case, what it does is it includes all of the contents of the IO stream file into this file.', 'start': 264.946, 'duration': 5.104}, {'end': 275.633, 'text': 'And I mean, literally, it just it copies and pastes that file into this file.', 'start': 270.33, 'duration': 5.303}, {'end': 279.996, 'text': 'And again, as I said, we will talk about header files in more depth in the future.', 'start': 275.833, 'duration': 4.163}, {'end': 282.177, 'text': "So don't worry too much if you don't understand this.", 'start': 280.036, 'duration': 2.141}, {'end': 288.841, 'text': 'For now, all you need to know is we include this file so that we can use the see out and see in functions.', 'start': 282.557, 'duration': 6.284}], 'summary': 'The preprocessor statement includes io stream file for using see out and see in functions.', 'duration': 32.922, 'max_score': 255.919, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os255919.jpg'}, {'end': 332.241, 'src': 'embed', 'start': 293.583, 'weight': 5, 'content': [{'end': 300.985, 'text': 'This is the stage where our compiler transforms all of this C++ code into actual machine code.', 'start': 293.583, 'duration': 7.402}, {'end': 305.847, 'text': "There are several important settings that determine how this actually happens, so let's take a brief look at them.", 'start': 301.245, 'duration': 4.602}, {'end': 310.109, 'text': 'In Visual Studio, we have these two important dropdown menus up here.', 'start': 306.127, 'duration': 3.982}, {'end': 314.071, 'text': "One's called a solution configuration and one's called a solution platform.", 'start': 310.809, 'duration': 3.262}, {'end': 318.434, 'text': 'By default, this will probably be set to debug and then either x86 or win32.', 'start': 314.291, 'duration': 4.143}, {'end': 319.254, 'text': "They're actually the same.", 'start': 318.474, 'duration': 0.78}, {'end': 323.016, 'text': "If we drop down the debug, you'll see that we've got two options, debug and release.", 'start': 319.594, 'duration': 3.422}, {'end': 325.858, 'text': 'These two options are defaults for any new project in Visual Studio.', 'start': 323.076, 'duration': 2.782}, {'end': 330.821, 'text': "And then under solution platform, you'll see we've got x64 and x86 as our two options.", 'start': 326.258, 'duration': 4.563}, {'end': 332.241, 'text': 'Again, these are just defaults.', 'start': 331.221, 'duration': 1.02}], 'summary': 'Compiler in visual studio converts c++ code to machine code with default debug and release options, and x86 and x64 platforms.', 'duration': 38.658, 'max_score': 293.583, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os293583.jpg'}, {'end': 486.1, 'src': 'embed', 'start': 458.61, 'weight': 6, 'content': [{'end': 462.091, 'text': 'But these are the rules that govern how our files will get compiled.', 'start': 458.61, 'duration': 3.481}, {'end': 467.134, 'text': 'You can see the difference between the debug and the release configuration pretty well if you go into the optimization tab.', 'start': 462.352, 'duration': 4.782}, {'end': 474.498, 'text': "Under optimization, if I change this to release, you'll see that the optimization is set to maximize speed, whereas in debug, it's set to disabled.", 'start': 467.314, 'duration': 7.184}, {'end': 481.039, 'text': "That's a great example of why debug mode by default is slower, a lot slower than release mode because optimization is turned off.", 'start': 474.818, 'duration': 6.221}, {'end': 486.1, 'text': 'But of course, turning off optimization will help us to debug our code as we will later discover.', 'start': 481.379, 'duration': 4.721}], 'summary': 'Debug mode is slower than release mode due to optimization differences.', 'duration': 27.49, 'max_score': 458.61, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os458610.jpg'}], 'start': 162.605, 'title': 'Understanding c++ syntax and building c++ program in visual studio', 'summary': 'Covers the syntax of c++ operators, treating them as functions, and provides examples. it also explains the process of compiling a c++ program in visual studio, including preprocessor statements, compiler settings, default configurations, and optimization settings.', 'chapters': [{'end': 234.183, 'start': 162.605, 'title': 'Understanding c++ syntax', 'summary': 'Explains the syntax of c++ operators, emphasizing that they should be thought of as functions, with examples and explanations to clarify their usage and functionality.', 'duration': 71.578, 'highlights': ['Operators in C++ are essentially functions, and their unusual syntax can be better understood when viewed as such, providing a clearer perspective on their usage and purpose.', 'The left angular brackets in C++ are actually just an overloaded operator, which should be perceived as a function, aiding in the understanding of their usage and functionality.', 'The example with cout.print and a parameter demonstrates that operators in C++ can be likened to functions, providing a clearer insight into their functionality and usage.', 'The functionality of pushing a string into the cout and causing it to be printed to the console is explained, highlighting the practical impact of utilizing operators as functions.', 'The purpose and functionality of the end line in C++ is elucidated, emphasizing its role in advancing the console to the next line after a specified operation.']}, {'end': 492.701, 'start': 234.544, 'title': 'Building c++ program in visual studio', 'summary': 'Explains the process of compiling a c++ program in visual studio, including preprocessor statements, compiler settings, and configuration and platform rules, with a focus on default settings and their impact on the output. it also discusses the differences between debug and release configurations and the impact of optimization settings.', 'duration': 258.157, 'highlights': ['The chapter explains the process of compiling a C++ program in Visual Studio, including preprocessor statements, compiler settings, and configuration and platform rules, with a focus on default settings and their impact on the output.', 'It discusses the differences between debug and release configurations and the impact of optimization settings.', "The preprocessor statement 'include IO stream' gets evaluated before compiling the file, including all the contents of the IO stream file into the current file, allowing the use of 'see out' and 'see in' functions.", "The default settings for debug and release configurations in Visual Studio include 'debug' and 'release' options for solution configuration, and 'x86' and 'x64' options for solution platform.", "The chapter highlights the impact of optimization settings, with 'release' configuration setting the optimization to maximize speed, while 'debug' configuration has optimization disabled, leading to slower execution."]}], 'duration': 330.096, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os162605.jpg', 'highlights': ['Operators in C++ are essentially functions, providing a clearer perspective on their usage and purpose.', 'The example with cout.print and a parameter demonstrates that operators in C++ can be likened to functions.', 'The left angular brackets in C++ are actually just an overloaded operator, aiding in the understanding of their usage and functionality.', 'The functionality of pushing a string into the cout and causing it to be printed to the console is explained.', 'The purpose and functionality of the end line in C++ is elucidated, emphasizing its role in advancing the console to the next line after a specified operation.', 'The chapter explains the process of compiling a C++ program in Visual Studio, including preprocessor statements, compiler settings, and configuration and platform rules.', 'It discusses the differences between debug and release configurations and the impact of optimization settings.', "The preprocessor statement 'include IO stream' gets evaluated before compiling the file, allowing the use of 'see out' and 'see in' functions.", "The default settings for debug and release configurations in Visual Studio include 'debug' and 'release' options for solution configuration, and 'x86' and 'x64' options for solution platform.", "The chapter highlights the impact of optimization settings, with 'release' configuration setting the optimization to maximize speed."]}, {'end': 732.154, 'segs': [{'end': 554.836, 'src': 'embed', 'start': 492.961, 'weight': 0, 'content': [{'end': 494.341, 'text': "So go check that out if you're interested.", 'start': 492.961, 'duration': 1.38}, {'end': 496.082, 'text': 'The link will be in the description below.', 'start': 494.521, 'duration': 1.561}, {'end': 499.402, 'text': 'Each CPP file in our project gets compiled.', 'start': 496.522, 'duration': 2.88}, {'end': 501.723, 'text': 'Header files do not get compiled at all.', 'start': 499.662, 'duration': 2.061}, {'end': 503.323, 'text': 'Just CPP files.', 'start': 502.103, 'duration': 1.22}, {'end': 511.21, 'text': "Remember, header files get included via a preprocessor statement called include into a CPP file and that's when they get compiled.", 'start': 503.763, 'duration': 7.447}, {'end': 516.433, 'text': "So we've got a bunch of CPP files that we've compiled and they actually get compiled individually.", 'start': 511.55, 'duration': 4.883}, {'end': 520.158, 'text': 'Every CPP file will get compiled into something called an object file.', 'start': 516.693, 'duration': 3.465}, {'end': 523.419, 'text': "The extension for that using Visual Studio's compiler is .", 'start': 520.518, 'duration': 2.901}, {'end': 529.423, 'text': 'obj. Once we have all of those individual OBJ files which are the result of compiling our CPP files,', 'start': 523.419, 'duration': 6.004}, {'end': 533.424, 'text': 'we need some way to stitch them together into one EXC file.', 'start': 529.423, 'duration': 4.001}, {'end': 535.625, 'text': "And that's where our friend the linker comes in.", 'start': 533.645, 'duration': 1.98}, {'end': 538.286, 'text': 'You can see the linker settings under this linker tab.', 'start': 535.865, 'duration': 2.421}, {'end': 544.208, 'text': 'But basically what the linker does is it takes all of those OBJ files and it glues them together.', 'start': 538.786, 'duration': 5.422}, {'end': 551.031, 'text': "So the linker's job is to take all of our OBJ files and stitch them together into one EXC file.", 'start': 544.569, 'duration': 6.462}, {'end': 554.836, 'text': 'Of course, the way that it does that is actually kind of complicated.', 'start': 551.371, 'duration': 3.465}], 'summary': 'Cpp files get compiled individually into obj files and then linked into one exc file.', 'duration': 61.875, 'max_score': 492.961, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os492961.jpg'}, {'end': 597.351, 'src': 'embed', 'start': 570.836, 'weight': 2, 'content': [{'end': 575.56, 'text': "You can see our output here shows that we're actually building this main.cpp file and that it succeeded.", 'start': 570.836, 'duration': 4.724}, {'end': 579.183, 'text': "If you don't want to hit Ctrl F7, you can actually bring up this compile button.", 'start': 575.92, 'duration': 3.263}, {'end': 584.727, 'text': 'You can do so by right clicking here and clicking on build and then going add or remove buttons,', 'start': 579.623, 'duration': 5.104}, {'end': 589.571, 'text': 'customize and then adding a command under build called compile.', 'start': 584.727, 'duration': 4.844}, {'end': 593.61, 'text': 'So if we hit that button, you can see that we get our file compiling.', 'start': 590.569, 'duration': 3.041}, {'end': 597.351, 'text': "If we were to make some kind of syntax error here, for example, I'm forgetting a semicolon.", 'start': 593.81, 'duration': 3.541}], 'summary': 'Output shows successful build of main.cpp file using compile button.', 'duration': 26.515, 'max_score': 570.836, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os570836.jpg'}, {'end': 600.692, 'src': 'heatmap', 'start': 570.836, 'weight': 1, 'content': [{'end': 575.56, 'text': "You can see our output here shows that we're actually building this main.cpp file and that it succeeded.", 'start': 570.836, 'duration': 4.724}, {'end': 579.183, 'text': "If you don't want to hit Ctrl F7, you can actually bring up this compile button.", 'start': 575.92, 'duration': 3.263}, {'end': 584.727, 'text': 'You can do so by right clicking here and clicking on build and then going add or remove buttons,', 'start': 579.623, 'duration': 5.104}, {'end': 589.571, 'text': 'customize and then adding a command under build called compile.', 'start': 584.727, 'duration': 4.844}, {'end': 593.61, 'text': 'So if we hit that button, you can see that we get our file compiling.', 'start': 590.569, 'duration': 3.041}, {'end': 597.351, 'text': "If we were to make some kind of syntax error here, for example, I'm forgetting a semicolon.", 'start': 593.81, 'duration': 3.541}, {'end': 600.692, 'text': "If I compile that file, you'll see that we get an error.", 'start': 597.751, 'duration': 2.941}], 'summary': 'Transcript demonstrates compiling main.cpp file and error handling.', 'duration': 29.856, 'max_score': 570.836, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os570836.jpg'}, {'end': 647.378, 'src': 'embed', 'start': 623.41, 'weight': 4, 'content': [{'end': 632.499, 'text': 'it basically pauses our output window looking for the word error and then grabs information from there that it can find and puts it into this error list.', 'start': 623.41, 'duration': 9.089}, {'end': 634.421, 'text': "So it's a good overview.", 'start': 632.859, 'duration': 1.562}, {'end': 636.264, 'text': 'You want to use it like an overview.', 'start': 634.521, 'duration': 1.743}, {'end': 642.532, 'text': "But if you want more details and if you want all the information about the error that you've just had, look at the output window.", 'start': 636.404, 'duration': 6.128}, {'end': 647.378, 'text': 'So for the rest of this series, I am actually going to be looking at this output window for error messages.', 'start': 642.792, 'duration': 4.586}], 'summary': 'A tool captures error information, useful for overview but detailed info in output window.', 'duration': 23.968, 'max_score': 623.41, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os623410.jpg'}, {'end': 740.237, 'src': 'heatmap', 'start': 707.475, 'weight': 0.733, 'content': [{'end': 709.696, 'text': "So I'm doing more than just building one file here.", 'start': 707.475, 'duration': 2.221}, {'end': 712.157, 'text': "I'm actually building the entire project.", 'start': 709.736, 'duration': 2.421}, {'end': 714.958, 'text': 'You can see that we actually get that exe file.', 'start': 712.377, 'duration': 2.581}, {'end': 721.701, 'text': 'And again, if we go back to our file explorer, that will actually be in the directory of your solution and then in the debug folder.', 'start': 715.218, 'duration': 6.483}, {'end': 724.662, 'text': "I know Visual Studio's default paths are a little bit weird.", 'start': 721.781, 'duration': 2.881}, {'end': 727.383, 'text': "I usually like to change them, but I'm trying not to complicate things here.", 'start': 724.702, 'duration': 2.681}, {'end': 732.154, 'text': "And there's our hello world.exe file, which we can run and it prints the text hello world.", 'start': 727.583, 'duration': 4.571}, {'end': 740.237, 'text': "So that's a pretty simple overview, but what happens when we have multiple C++ files? Let's take a look at a simple example.", 'start': 733.214, 'duration': 7.023}], 'summary': 'Building the entire project produces the exe file in the debug folder, allowing execution of the program.', 'duration': 32.762, 'max_score': 707.475, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os707475.jpg'}], 'start': 492.961, 'title': 'C++ compilation and linking process', 'summary': "Explains the compilation of cpp files, where each file is compiled into an object file (.obj) and then linked together by the linker into one executable file (.exe). it also highlights the role of header files and the preprocessor statement 'include'. additionally, it covers the process of compiling c++ files in visual studio, including using shortcuts like ctrl f7 and the compile button, handling syntax errors, and understanding the output window and error list.", 'chapters': [{'end': 554.836, 'start': 492.961, 'title': 'C++ compilation and linking process', 'summary': "Explains the compilation of cpp files, where each file is compiled into an object file (.obj) and then linked together by the linker into one executable file (.exe). it also highlights the role of header files and the preprocessor statement 'include'.", 'duration': 61.875, 'highlights': ['Each CPP file in the project gets compiled, while header files do not get compiled at all. Header files are included via a preprocessor statement called include into a CPP file.', 'Every CPP file will get compiled into an object file with the extension .obj.', "The linker's job is to take all the OBJ files and stitch them together into one EXE file."]}, {'end': 732.154, 'start': 554.956, 'title': 'Compiling c++ files in visual studio', 'summary': 'Explains the process of compiling c++ files in visual studio, including using shortcuts like ctrl f7 and the compile button, handling syntax errors, and understanding the output window and error list.', 'duration': 177.198, 'highlights': ['The process of compiling C++ files in Visual Studio is demonstrated, including using shortcuts like Ctrl F7 and the compile button.', 'Handling syntax errors is explained, emphasizing the unreliability of the error list and the importance of using the output window for detailed error information.', 'The generation of object files and executable files in Visual Studio is demonstrated, with emphasis on file locations and the building of the entire project.']}], 'duration': 239.193, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os492961.jpg', 'highlights': ['Each CPP file in the project gets compiled, while header files do not get compiled at all. Header files are included via a preprocessor statement called include into a CPP file.', "The linker's job is to take all the OBJ files and stitch them together into one EXE file.", 'The process of compiling C++ files in Visual Studio is demonstrated, including using shortcuts like Ctrl F7 and the compile button.', 'Every CPP file will get compiled into an object file with the extension .obj.', 'Handling syntax errors is explained, emphasizing the unreliability of the error list and the importance of using the output window for detailed error information.']}, {'end': 1004.566, 'segs': [{'end': 775.659, 'src': 'embed', 'start': 733.214, 'weight': 0, 'content': [{'end': 740.237, 'text': "So that's a pretty simple overview, but what happens when we have multiple C++ files? Let's take a look at a simple example.", 'start': 733.214, 'duration': 7.023}, {'end': 745.139, 'text': "So suppose that we've got our hollow world printing to the console here, but I don't wanna use the cout function.", 'start': 740.637, 'duration': 4.502}, {'end': 747.14, 'text': 'I wanna use my own logging function.', 'start': 745.179, 'duration': 1.961}, {'end': 749.801, 'text': 'And then maybe that will wrap this cout function.', 'start': 747.58, 'duration': 2.221}, {'end': 759.785, 'text': "So let's create a function called log, which will take in a C string called message and print that message.", 'start': 750.141, 'duration': 9.644}, {'end': 762.774, 'text': 'to the console, simple enough.', 'start': 761.192, 'duration': 1.582}, {'end': 769.364, 'text': "Now don't worry, if you're not sure what a const char pointer is, we're gonna talk about strings in another video.", 'start': 763.175, 'duration': 6.189}, {'end': 775.659, 'text': 'For now, all you have to know is that a const char pointer is basically just a type that can hold a string of text.', 'start': 769.994, 'duration': 5.665}], 'summary': 'Introduction to creating a custom logging function in c++ for multiple files.', 'duration': 42.445, 'max_score': 733.214, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os733214.jpg'}, {'end': 806.923, 'src': 'heatmap', 'start': 780.263, 'weight': 0.841, 'content': [{'end': 785.208, 'text': 'we call this log function and then pass in hello world as a parameter.', 'start': 780.263, 'duration': 4.945}, {'end': 789.492, 'text': 'We can go ahead and hit the local Windows debugger button here just to make sure that it still works.', 'start': 785.708, 'duration': 3.784}, {'end': 790.833, 'text': 'As you can see, it does.', 'start': 789.792, 'duration': 1.041}, {'end': 794.015, 'text': "Fantastic, we've written our first function.", 'start': 791.974, 'duration': 2.041}, {'end': 794.716, 'text': 'That was easy.', 'start': 794.175, 'duration': 0.541}, {'end': 802.32, 'text': "So now let's take that function and put it into a different file because I don't want to have this main.cpp file cluttered with all of my code.", 'start': 794.976, 'duration': 7.344}, {'end': 806.923, 'text': 'I want to separate my code into multiple files to keep things nice and clean and organized.', 'start': 802.7, 'duration': 4.223}], 'summary': 'Developed a log function, tested, and organized code into separate files.', 'duration': 26.66, 'max_score': 780.263, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os780263.jpg'}, {'end': 823.11, 'src': 'embed', 'start': 794.976, 'weight': 1, 'content': [{'end': 802.32, 'text': "So now let's take that function and put it into a different file because I don't want to have this main.cpp file cluttered with all of my code.", 'start': 794.976, 'duration': 7.344}, {'end': 806.923, 'text': 'I want to separate my code into multiple files to keep things nice and clean and organized.', 'start': 802.7, 'duration': 4.223}, {'end': 810.765, 'text': "We'll make a new file under source files by going right click add new item.", 'start': 807.223, 'duration': 3.542}, {'end': 812.186, 'text': "We'll make a cpp file.", 'start': 810.945, 'duration': 1.241}, {'end': 814.327, 'text': "We'll call it log.cpp.", 'start': 812.406, 'duration': 1.921}, {'end': 816.898, 'text': "and we'll click add.", 'start': 816.277, 'duration': 0.621}, {'end': 823.11, 'text': "So what I'm going to do here is I'm going to go back to main and I'm going to cut this log function.", 'start': 817.179, 'duration': 5.931}], 'summary': 'Separate log function into new file for organized code', 'duration': 28.134, 'max_score': 794.976, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os794976.jpg'}, {'end': 903.421, 'src': 'embed', 'start': 878.179, 'weight': 2, 'content': [{'end': 885.582, 'text': "We also get a complaint about CIN, but we already know that that's because we removed the IO stream include and we have no idea what CIN is.", 'start': 878.179, 'duration': 7.403}, {'end': 890.065, 'text': 'We can restore that include and our problem should be fixed.', 'start': 886.043, 'duration': 4.022}, {'end': 893.969, 'text': 'However, you can see that log is still not found.', 'start': 890.845, 'duration': 3.124}, {'end': 903.421, 'text': "So what's going on here? We've moved a function from one file into the other, and we are compiling each file separately for the minute.", 'start': 894.329, 'duration': 9.092}], 'summary': 'Complaint about cin resolved by restoring include, log still not found after moving function between files.', 'duration': 25.242, 'max_score': 878.179, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os878179.jpg'}, {'end': 971.341, 'src': 'embed', 'start': 942.751, 'weight': 3, 'content': [{'end': 944.273, 'text': 'Declarations and definitions.', 'start': 942.751, 'duration': 1.522}, {'end': 949.939, 'text': 'Declarations are just a statement which say, hey, this symbol, this function exists.', 'start': 944.593, 'duration': 5.346}, {'end': 955.045, 'text': 'And then a definition is something that says, this is what this function is.', 'start': 950.28, 'duration': 4.765}, {'end': 957.167, 'text': 'This is the body of this function.', 'start': 955.265, 'duration': 1.902}, {'end': 960.911, 'text': "Let's go ahead and write a declaration for our log function.", 'start': 957.688, 'duration': 3.223}, {'end': 964.294, 'text': 'A declaration looks very similar to an actual definition.', 'start': 961.191, 'duration': 3.103}, {'end': 971.341, 'text': 'This is something called a definition, because you can see that not only have we declared something with the name log a function with the name log,', 'start': 964.675, 'duration': 6.666}], 'summary': 'Declarations state existence, definitions specify function. example: log function.', 'duration': 28.59, 'max_score': 942.751, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os942751.jpg'}], 'start': 733.214, 'title': 'Managing c++ files', 'summary': 'Covers handling and separating c++ files, including creating a custom logging function, utilizing const char pointers, resolving compilation errors, and understanding declarations and definitions.', 'chapters': [{'end': 775.659, 'start': 733.214, 'title': 'Handling multiple c++ files', 'summary': 'Explains how to handle multiple c++ files, showcasing an example of creating a custom logging function and addressing the concept of const char pointers.', 'duration': 42.445, 'highlights': ['The chapter demonstrates creating a custom logging function to replace the cout function, providing a practical example of handling multiple C++ files.', 'The concept of const char pointers is briefly introduced, with the assurance of further explanation in a subsequent video.']}, {'end': 1004.566, 'start': 775.979, 'title': 'Separating code into multiple files', 'summary': 'Explains the process of separating code into multiple files in c++, including the creation of a new file, resolving compilation errors, and understanding the concepts of declarations and definitions.', 'duration': 228.587, 'highlights': ['The process of separating code into multiple files is explained, involving the creation of a new file and moving a function into it.', 'Compilation errors related to the inclusion of iostream and the recognition of the log function are addressed and resolved.', 'The distinction between declarations and definitions in C++ is explained, outlining their respective roles in specifying the existence and implementation of functions.']}], 'duration': 271.352, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os733214.jpg', 'highlights': ['The chapter demonstrates creating a custom logging function to replace the cout function, providing a practical example of handling multiple C++ files.', 'The process of separating code into multiple files is explained, involving the creation of a new file and moving a function into it.', 'Compilation errors related to the inclusion of iostream and the recognition of the log function are addressed and resolved.', 'The distinction between declarations and definitions in C++ is explained, outlining their respective roles in specifying the existence and implementation of functions.', 'The concept of const char pointers is briefly introduced, with the assurance of further explanation in a subsequent video.']}, {'end': 1204.427, 'segs': [{'end': 1067.257, 'src': 'embed', 'start': 1004.846, 'weight': 0, 'content': [{'end': 1007.647, 'text': 'So you might be wondering at this stage well, hey,', 'start': 1004.846, 'duration': 2.801}, {'end': 1014.289, 'text': "how does the compiler know that we actually have a log function in another file if we're just compiling this one file?", 'start': 1007.647, 'duration': 6.642}, {'end': 1017.43, 'text': "And the answer is it, doesn't it just it trusts us.", 'start': 1014.829, 'duration': 2.601}, {'end': 1026.373, 'text': 'So then your second question should be, how does it actually run the right code? That is where the linker comes in.', 'start': 1017.65, 'duration': 8.723}, {'end': 1034.336, 'text': 'When we build our entire project, not just this one file, but if I actually right click and hit build once our files have been compiled,', 'start': 1026.693, 'duration': 7.643}, {'end': 1041.358, 'text': 'the linker will actually find the definition of that log function and wire it up to the log function that we call here in main.cpp.', 'start': 1034.336, 'duration': 7.022}, {'end': 1045.679, 'text': "If it can't find that definition, that's when we get a linker error.", 'start': 1041.617, 'duration': 4.062}, {'end': 1050.961, 'text': 'Now, linking errors are something that look very scary and a lot of people get scared.', 'start': 1045.92, 'duration': 5.041}, {'end': 1053.162, 'text': "So let's go ahead and look at an example of that.", 'start': 1051.161, 'duration': 2.001}, {'end': 1059.929, 'text': "So right now, if I just run my program, you'll see that it still prints out the text hello world and everything runs successfully.", 'start': 1053.382, 'duration': 6.547}, {'end': 1063.173, 'text': "However, let's remove this or at least change it a little bit.", 'start': 1060.029, 'duration': 3.144}, {'end': 1066.276, 'text': "For example, I'll change this to logger.", 'start': 1063.633, 'duration': 2.643}, {'end': 1067.257, 'text': 'Save the file.', 'start': 1066.577, 'duration': 0.68}], 'summary': 'The compiler trusts us to have a log function in another file, and the linker finds and connects the function when building the entire project.', 'duration': 62.411, 'max_score': 1004.846, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os1004846.jpg'}, {'end': 1198.955, 'src': 'embed', 'start': 1102.168, 'weight': 2, 'content': [{'end': 1104.509, 'text': "and you're referencing this function inside main.", 'start': 1102.168, 'duration': 2.341}, {'end': 1108.831, 'text': 'An unresolved external symbol means that the linker was unable to resolve a symbol.', 'start': 1104.809, 'duration': 4.022}, {'end': 1111.252, 'text': "Remember, the linker's job is to resolve symbols.", 'start': 1109.031, 'duration': 2.221}, {'end': 1118.635, 'text': "It has to wire up functions and it couldn't find what to wire log to, because we don't have a function called log.", 'start': 1111.352, 'duration': 7.283}, {'end': 1121.037, 'text': "that's actually defined that has a body.", 'start': 1119.235, 'duration': 1.802}, {'end': 1124.72, 'text': 'So the way that we can fix this is by fixing our function.', 'start': 1121.357, 'duration': 3.363}, {'end': 1128.624, 'text': 'We need to provide a definition for this log function.', 'start': 1125.121, 'duration': 3.503}, {'end': 1131.807, 'text': 'In other words, we have to provide a body for this log function.', 'start': 1129.204, 'duration': 2.603}, {'end': 1133.248, 'text': "Doesn't have to be inside this file.", 'start': 1131.847, 'duration': 1.401}, {'end': 1136.031, 'text': 'It can be inside main, but it has to be somewhere.', 'start': 1133.809, 'duration': 2.222}, {'end': 1139.314, 'text': "And if we compile this, you'll see that we don't get any errors.", 'start': 1136.411, 'duration': 2.903}, {'end': 1146.799, 'text': "If we go back to our file explorer and look at what we've got inside our intermediate folder here, you'll see that we've got two OBJ files,", 'start': 1139.654, 'duration': 7.145}, {'end': 1151.022, 'text': 'because the compiler generates an object file for each of our CPP files.', 'start': 1146.799, 'duration': 4.223}, {'end': 1154.664, 'text': 'The linker will then take them and stitch them together into an exe file.', 'start': 1151.322, 'duration': 3.342}, {'end': 1163.708, 'text': 'So in our lovely example, we have our log definition inside this log obj file and our main function inside our main.obj file.', 'start': 1154.904, 'duration': 8.804}, {'end': 1171.512, 'text': 'And so the linker will basically take that log definition from log and put it into a common binary.', 'start': 1164.288, 'duration': 7.224}, {'end': 1177.593, 'text': 'which is our holoworld.exe file which contains a definition for both main and log.', 'start': 1172.552, 'duration': 5.041}, {'end': 1180.654, 'text': 'And that is a basic overview of how C++ works.', 'start': 1177.833, 'duration': 2.821}, {'end': 1186.095, 'text': 'Again, I highly encourage you to check out the in-depth videos about how compiling and linking works,', 'start': 1181.094, 'duration': 5.001}, {'end': 1188.896, 'text': "because they're going to be way more information than this video.", 'start': 1186.095, 'duration': 2.801}, {'end': 1195.497, 'text': 'This video was just made to show you kind of an overview of the pipeline of how you go from source files to an actual binary.', 'start': 1189.136, 'duration': 6.361}, {'end': 1198.955, 'text': "As always, don't forget to follow me on Twitter and Instagram.", 'start': 1195.908, 'duration': 3.047}], 'summary': 'Resolving symbols in c++ by providing function definitions, explained in the context of compiling and linking process.', 'duration': 96.787, 'max_score': 1102.168, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os1102168.jpg'}], 'start': 1004.846, 'title': 'Compilation, linking, and resolving errors', 'summary': 'Explains the role of compiler, linker, and the process of linking functions in project build, addressing linker errors and their impact on program execution. it also provides insights into fixing unresolved external symbol errors and a detailed overview of the c++ compilation and linking process, including the generation of obj and exe files.', 'chapters': [{'end': 1083.352, 'start': 1004.846, 'title': 'Compiler, linker, and linking errors', 'summary': 'Explains how the compiler trusts the presence of functions in other files, and the role of the linker in finding and linking the function definitions during the project build process, with emphasis on the consequences of linker errors and their impact on program execution.', 'duration': 78.506, 'highlights': ['The linker finds the definition of a function and links it to the function call in the main file during project build, leading to a linker error if the definition is not found.', 'Linking errors can occur during program execution, resulting in scary-looking error messages and impacting the successful execution of the program.', "The compiler trusts the presence of a function in another file when compiling a single file, with no explicit checking for the function's existence.", 'When attempting to build the project, the linker searches for the definition of functions used in the project and links them together, ensuring the correct execution of the program.']}, {'end': 1139.314, 'start': 1083.573, 'title': 'Fixing unresolved external symbol', 'summary': "Explains how to fix an unresolved external symbol error by providing a definition for the function 'log' which is being referenced in the main function, enabling the linker to resolve the symbol and eliminating the error.", 'duration': 55.741, 'highlights': ["An unresolved external symbol called 'log' is causing an error, and it needs a definition to be provided with a body to resolve the issue. (Relevance: 5)", "The error occurs because the linker was unable to resolve the symbol 'log' which is being referenced in the main function. (Relevance: 4)", "It's necessary to provide a definition for the 'log' function, and it doesn't have to be inside the current file. (Relevance: 3)", "The function 'log' needs a body to be provided somewhere in order to fix the unresolved external symbol error. (Relevance: 2)", "By providing a definition for the 'log' function, the error can be resolved, and the code can be compiled without any errors. (Relevance: 1)"]}, {'end': 1204.427, 'start': 1139.654, 'title': 'C++ compilation and linking process', 'summary': 'Explains how c++ source files are compiled into object files, and then linked to create an executable file, with an example of generating obj and exe files and an overview of the c++ compilation and linking process.', 'duration': 64.773, 'highlights': ['The compiler generates an object file for each CPP file, and the linker stitches them together into an exe file', 'The linker combines the log definition from the log.obj file and the main function from the main.obj file into the holoworld.exe file', 'Encouragement to check out in-depth videos about compiling and linking process for more information']}], 'duration': 199.581, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/SfGuIVzE_Os/pics/SfGuIVzE_Os1004846.jpg', 'highlights': ['The linker finds the definition of a function and links it to the function call in the main file during project build, leading to a linker error if the definition is not found.', 'Linking errors can occur during program execution, resulting in scary-looking error messages and impacting the successful execution of the program.', "An unresolved external symbol called 'log' is causing an error, and it needs a definition to be provided with a body to resolve the issue. (Relevance: 5)", "The error occurs because the linker was unable to resolve the symbol 'log' which is being referenced in the main function. (Relevance: 4)", "It's necessary to provide a definition for the 'log' function, and it doesn't have to be inside the current file. (Relevance: 3)", "The function 'log' needs a body to be provided somewhere in order to fix the unresolved external symbol error. (Relevance: 2)", "By providing a definition for the 'log' function, the error can be resolved, and the code can be compiled without any errors. (Relevance: 1)", 'The compiler generates an object file for each CPP file, and the linker stitches them together into an exe file', 'The linker combines the log definition from the log.obj file and the main function from the main.obj file into the holoworld.exe file', "The compiler trusts the presence of a function in another file when compiling a single file, with no explicit checking for the function's existence.", 'When attempting to build the project, the linker searches for the definition of functions used in the project and links them together, ensuring the correct execution of the program.', 'Encouragement to check out in-depth videos about compiling and linking process for more information']}], 'highlights': ['The main function is called the entry point for C++ programs, and it dictates the order of code execution.', 'Preprocessor statements, such as include, are processed before actual compilation and are used to include contents from header files like iostream.', 'Operators in C++ are essentially functions, providing a clearer perspective on their usage and purpose.', 'The example with cout.print and a parameter demonstrates that operators in C++ can be likened to functions.', 'Each CPP file in the project gets compiled, while header files do not get compiled at all. Header files are included via a preprocessor statement called include into a CPP file.', "The linker's job is to take all the OBJ files and stitch them together into one EXE file.", 'The process of compiling C++ files in Visual Studio is demonstrated, including using shortcuts like Ctrl F7 and the compile button.', 'The chapter demonstrates creating a custom logging function to replace the cout function, providing a practical example of handling multiple C++ files.', 'The linker finds the definition of a function and links it to the function call in the main file during project build, leading to a linker error if the definition is not found.', 'Linking errors can occur during program execution, resulting in scary-looking error messages and impacting the successful execution of the program.']}