an elaborative and explanatory video, feeling lucky that i have discovered this channel
@abelashenafi6291 Жыл бұрын
I'm really liking your videos. You just became my go to person when I want to learn about some advanced C++ topics. I did my own experiment after watching this video. If someone really wants to truly understand the difference between a constant and a Macros in C or C++; one could simply try to print out the memory location of both, and as this video vividly explained, marcos are just preprocessor directive that replace your macros in your program, which are NOT stored in memory. Doing this experiment helped in finally understanding the difference between marcros and const variables. I strongly suggest everyone watching this video to do the same :).
@wiktorwektor1233 жыл бұрын
C/C++ compilers are working ALWAYS in 4 phases: 1) Preprocessor (everything starting from #) 2) Compiler 3) Assembler 4) Linker
@arberhoxha85232 жыл бұрын
Wasn't the assembler optional?
@emjaqua2 жыл бұрын
Awesome videos. Really impressed with the direct, focused information.
@ifeanyizionchidiebere6369 Жыл бұрын
i am now hooked up to your videos, you are the best teacher.😊🙃
@Принуждениекмиру-ь2ц2 жыл бұрын
Man, you're the best in KZbin. Thanks a lot. 👍❤️
@Ejeby3 жыл бұрын
9:15 why would one prefer to use constants instead of macros (aka symbolic constants?) if the output of preprocessing macros offers better debugging?
@CodeVault3 жыл бұрын
I'm not sure what you mean by this: "the output of preprocessing macros offers better debugging" The main reason I said that is because constants have types which can be checked at compile time, while, macros don't. With macros, of course you will get a compile time error most of the time but it could be confusing. I guess, with enough experience it doesn't really matter
@Ejeby3 жыл бұрын
9:45 how does one find the computational cost of variable dereferencing? And compare that to cost of macro/preprocessing?
@Ejeby3 жыл бұрын
10:15 I understand that there’s usually no difference if you’re using a “modern compiler”
@CodeVault3 жыл бұрын
Hmm... for the most part the difference would be negligeble (but remains to be tested). I say that because, constants do actually get replaced by hard-coded values at compile time (similar as to macros) since compilers now understand that there is little benefit to allocating memory for those constants at runtime so they are just stored as literals
@mikeyo51542 жыл бұрын
Great discussion
@PeacelandMusic2 жыл бұрын
Is it possible to use a macro to define an element of an array? I tried it with int const sameVar and it didn't work (error on that line). I want to be able to change elements of my array using a variable that is easy to access. The other reason is that I have 3 columns in the array and 2 of them need to be the same value, but they are not in succession. They skip: myArray[3] { (x=zVar ), y , zVar }. Can this be done? Ultimately hoping to do this as a multidimensional array in C. Thank you! Peace
@CodeVault2 жыл бұрын
Hmm... I'm not entirely sure what you're asking. Can you send me the code so I can better understand?
@chriso.wilkie79154 жыл бұрын
Oh man, I wish I could hire you as a tutor for few hours. I have so much to ask you
@CodeVault4 жыл бұрын
Just send me a private message on discord.code-vault.net and we can figure out the details!
@Ejeby3 жыл бұрын
9:55 constant const int
@abdoroma6928 Жыл бұрын
So cool
@TalhaAbid-l2b8 ай бұрын
The best
@zaabimahdi4 жыл бұрын
Hallo ! thank you again for the the high informative videos ! Please , i have a question that is depressing me now for 2 weeks ... It's about the Macro EOF (End Of File) ... "i'am using getline" I understand how to use it in an infinte while loop ... But please could you explain me how getline detect the end of file ? i know that Getline return the number of bytes that was read in success , and return -1 on failure or EOF ... But how Getline detect the end of file so it's return -1 ? i was searching on the internet for hours , the only answer that i found : ctrl+d to simulate the EOF on linux ... which is not the case if you want to develop a program that keeps reading the input line and detect the end of FILE by itself and not the USER ! i would be very happy if you could answer me ! Thank you .