Buckys C++ Programming Tutorials - 49 - this

  Рет қаралды 308,335

thenewboston

thenewboston

Күн бұрын

Пікірлер: 237
@StaticBlaster
@StaticBlaster Жыл бұрын
I love Bucky's sense of humor. Funny dude, engaging, entertaining and makes coding and learning fun.
@MultiKB13
@MultiKB13 7 жыл бұрын
In short: - without using 'this' is implicitly referencing the attribute but this can cause issues if you have a function parameter that has the same name as the variable, eg. setting h to the value of a parameter called h: h = h; - this-> is explicitly referencing the attribute and it's the least prone to errors and it's easier for the programmers to read. Also, it avoids the previous potential problem by doing this->h = h; - (*this).h has no difference between the previous one. This one is more tedious to type out, so "this->h" is a short-hand notation for (*this).h
@KHANPIN
@KHANPIN 4 жыл бұрын
Good summary dawg
@yigitbulut4972
@yigitbulut4972 2 жыл бұрын
How come there's no difference may i ask? Not to correct or debate, just out of curiosity. In "this->h" our 'this' is a pointer and it points at the memory address of the written data. *Pointer->Data* our pointer questions the address of the data and then temporarily becomes the adress *Adress->Data (0x0014 -> h)* which is *(0x0014 -> 23)* but our pointer still exists, value is temporarily stored at *this*. In "(*this).h there are no pointers. Just the memory address, right?
@patrickjdarrow
@patrickjdarrow 8 жыл бұрын
Someone has an ex named Hannah..
@ZiiiP2142
@ZiiiP2142 8 жыл бұрын
xD
@ishi92
@ishi92 8 жыл бұрын
0:35 Im gna name my class hannah...and actually....uhhhhh I already messed up ^_^
@ishi92
@ishi92 8 жыл бұрын
4:20 Hannah ho(23); sealed.
@13taras
@13taras 8 жыл бұрын
It's his sister's name lol
@johnnycat995
@johnnycat995 8 жыл бұрын
and sally
@orcasem
@orcasem 11 жыл бұрын
Thanks so much for putting out this great content! You have no idea of how much it's done for me! ;)
@sylphid96
@sylphid96 9 жыл бұрын
"so hopefully i confused you guys" ok
@mortvald
@mortvald 8 жыл бұрын
I farted yesterday.
@karlrichardson7548
@karlrichardson7548 Жыл бұрын
THANK YOU!!!!!!! Ive been struggling with "this" forever!!!! This is the first time anyone has explained it in a way that actually makes sense to me. THANK YOU!!!!!!!
@GamerGurke15
@GamerGurke15 9 жыл бұрын
if you would have made your printCrap like following it would be more clear that h in that case refers to the local variable with the value 42 instead of the global with a value of 23: void Hannah::printCrap(){ int h = 42; cout
@TheIsac02
@TheIsac02 7 жыл бұрын
Gamer Gurke I know this comment is old. But just to make sure i get it right. When you do... cout
@GamerGurke15
@GamerGurke15 7 жыл бұрын
DaKingZ this-> is a reference to the wrapping class. In this case Hannah. Therefore writing this->h is an absolute indication to use the outer h (with a value of 23). When, on the other side, no absolute indication is given and just h is written, the compiler will take the inner most h he finds. Which, in this case, is the local h with a value of 42. Hope this clarifies the usage of pointers inside member functions.
@steven9492
@steven9492 7 жыл бұрын
So this-> h takes the outermost h? Would the equivalent in this case be HannahObject->h?
@ImaginaryHuman072889
@ImaginaryHuman072889 7 жыл бұрын
Gamer Gurke your explanation makes sense but I still don't understand "why" this would ever be done. can you explain? it seems like poor programming practice to have a local variable inside a member function with the same name as a member variable in the class. why not just name them different names and then "this" would never even need to be used? obviously there is some reason that I'm missing. thank you.
@HealthyPanic
@HealthyPanic 4 жыл бұрын
@@GamerGurke15 So you mean it acts like a unary scope resolution operator here?
@cgme7076
@cgme7076 7 жыл бұрын
Hannah(int), this is used with prototypes. Let's look at what a prototype is "a prototype is a reference point for the compiler, so that it knows a function with a certain parameter(s) is going to he used at some point". The name of the parameter IS NOT needed when you create the prototype, because it just needs to know what kind of data is being passed in so that it can throw compile errors if the programmer enters something that isn't of that data type. Let's say you're playing a game with your friends where you all have to throw shapes into holes. The directions (prototype) for the game, specify that a square shape fits into a square hole. So, your friend (the programmer) throws a circle at the hole (function). The function doesn't know what to do with the shape yet, but it knows the shape has to be a square, so it says "NOPE" and you now have to correct the error by throwing in a square object. Hope this helps
@vil3n80
@vil3n80 3 жыл бұрын
This-> video was way more helpful than the hour long classes im paying for.
@SuryakantSingh5
@SuryakantSingh5 10 жыл бұрын
U are a natural teacher bucky!! thank you for this great work :)
@nasimahmedbulbul4401
@nasimahmedbulbul4401 2 жыл бұрын
I've been looking for this for a while. Your this is the best this. Thanks man
@thestarinthesky_
@thestarinthesky_ 4 жыл бұрын
It is 2020, and this video is still amazing.
@tanmaysah6321
@tanmaysah6321 3 жыл бұрын
@Samira I am watching and learning from this video in 2021
@tanmaysah6321
@tanmaysah6321 3 жыл бұрын
I am watching and learning from this video in 2021
@mortvald
@mortvald 8 жыл бұрын
10 minute to say: "this is a pointer that point to the class itself".
@Argon014
@Argon014 13 жыл бұрын
Please make sure you update your website, and thank you Bucky for all of the tutorials :D
@luyuwang379
@luyuwang379 5 жыл бұрын
because [h] is the parameter of the class constructor. when we firstly use the value of[h], the pointer [this] pointed to the address of [h]. In the next round, we use[this], which is equal to address of the lastest value, i.e. [h]. To get the value which is pointed by the pointer [this], we should use the format of [this->h]. So, now the current pointer pointed to the pointer's address. the format[*this] is used to get the content which pointed by the current pointer, i.e.[Hannah]. So, [*this] means a[Object].So, the syntax of[*(this).h] means call the variable from object[*this].
@evilnekowantznobs
@evilnekowantznobs 8 жыл бұрын
Holy crap! That 3rd one sounds ridiculously useful!
@HankGreenburg
@HankGreenburg 12 жыл бұрын
I'm getting really tired of my classes not being included in my project... Also, surprised there aren't more comments about the "Hannah ho"
@damindadineshimaduwagamage9044
@damindadineshimaduwagamage9044 11 жыл бұрын
thanks brother, your videos are simple ,and thus understandable
@lCira9
@lCira9 12 жыл бұрын
this is useful when you're making a setter function inside the class, for example int A is a member of a class, when you can set A in a function like this, void setA(int A) { this->A = A; } it is useful for when you don't want the parameter to have a different name,
@Marius-vw9hp
@Marius-vw9hp 8 жыл бұрын
printCrap makes me happy every time.
@EnforcersNL
@EnforcersNL 12 жыл бұрын
I assume you haven't watched his tutorial on member initializers, but he uses that technique to set h to the passed value. The constructor of the hannah class contains this member initializer, 'Hannah::Hannah(int num):h(num){}' does the same as: 'Hannah::Hannah(int num){h = num;}' There are some advantages to using the member initializer, such as performance. Code guru has a nice thread about advantages of using this technique, google it :)
@cubito455
@cubito455 13 жыл бұрын
@mjdhiru not really, the use of member initializers is just a more efficient way of initializing members.
@ayasaki.pb_787
@ayasaki.pb_787 8 жыл бұрын
Why in the header file of "Hannah", the constructor Hannah(int) does not need the variable name "num"? isn't that we should keep them same in both the header file and the class file?
@ayasaki.pb_787
@ayasaki.pb_787 8 жыл бұрын
thx!
@040134
@040134 12 жыл бұрын
There is another tutorial (C++ tutorial 26 by DevHQLessons) that actually shows why and when is it useful to actually use the "this" keyword.
@fiotakis7
@fiotakis7 10 жыл бұрын
in order to understund it better you can try this out void hanna::print() { cout
@cornerzzgame
@cornerzzgame 10 жыл бұрын
How is the current object defined? If working with more than one object, at what point does an object become current? Your tutorials are wonderful, thank you. :)
@apostolis.diamantopoulos
@apostolis.diamantopoulos 10 жыл бұрын
the current object is the one that uses the command at the time... e.g. let me explain with a bit of data structure. lets say you create an object of any class, and you want to connect it to another object of the same class. the class would be like: class Object { Object next; Object() { } //default constructor Object (Object ob) { next = ob; }//constructor that connects the current object to the next one }; so then in main you would create an object with the default constructor like: Object obj1(); and then you would make 2 new objects that are connected to the previous ones: Object obj2(obj1); Object obj3(obj2); when you use the obj2 like: obj2.next = obj3; you use the obj1 and make it equal to obj3 (cause obj2.next is obj1) . but the command is made via the obj2 so THE CURRENT OBJECT IS OBJ2 (sorry for caps but i couldn't make it bold xD) another example is when using obj1.next = obj3; here obj1.next has no value so when you use the obj1.next command THE CURRENT OBJECT IS OBJ1. i don't know if you understand this (cause in my mind it makes sense) but anyways I tried :P to have a visual, when you create them they will be like: ( --> meaning next) obj3 --> obj2 --> obj1 --> null (namely nothing)
@EnforcersNL
@EnforcersNL 12 жыл бұрын
no problem :) we're all here to get (re)educated, so helping each other should be mandatory :P
@amadorTJ
@amadorTJ 8 жыл бұрын
int i=5; int *p=&i ;; cout
@iXenoCider
@iXenoCider 12 жыл бұрын
He is welcoming you back to his channel. And the he is saying what C++ tutorial it is.
@katzwhacky
@katzwhacky 6 жыл бұрын
Bucky, The memory location would be printed as a hexadecimal number. This is true. However, that number would not have a 'J' in it because the digits in hexadecimal are only represented by 0 through 9 and A through F.
@AminKhan
@AminKhan 5 жыл бұрын
Jamey Bryce Yes, that’s why he said yada yada too
@Impulse_Photography
@Impulse_Photography 3 жыл бұрын
Maybe it was only a point he was trying to make, and not to be taken so literal. Jeez !!
@zzHackedTutorialzz
@zzHackedTutorialzz 9 жыл бұрын
(*this).tut was great
@icantfindnonameforme
@icantfindnonameforme 11 жыл бұрын
man thnx so much you are my hero i woud never manage to do thet what are you doing :)
@molochtauren4685
@molochtauren4685 4 жыл бұрын
fail. next video we will continue this. next video, we will do this in another video. where is this other video? its been 9 years.
@GodlikeGER
@GodlikeGER 13 жыл бұрын
Finally Brad Pitt teaching me again
@unknownguy2092
@unknownguy2092 4 жыл бұрын
9 years old comment with no like. heres one for u. ur welcome💩
@unknownguy2092
@unknownguy2092 4 жыл бұрын
r u dead?
@swanhtetkyawswar2141
@swanhtetkyawswar2141 4 жыл бұрын
@@unknownguy2092 lol XD
@unknownguy2092
@unknownguy2092 4 жыл бұрын
buckey: i will show how to use this keyboard me: which keyboard?
@khasha6166
@khasha6166 4 жыл бұрын
looooool
@swanhtetkyawswar2141
@swanhtetkyawswar2141 4 жыл бұрын
LOOOOOOOOOOOOOOOOL
@Errors404
@Errors404 4 жыл бұрын
I'm either bad at english or bad at understanding .. it gets more confusing the more i try to visualise ..
@Mycrosss
@Mycrosss 5 жыл бұрын
This was a bad example. Think of it this way - If you have a function printName(string name) under the Person class which contains a string name variable, you would have to assign the OBJECT'S name like this - void Person::printName(string name){ this->name = name; } this->name is the variable of the class(object), while name is the variable we get from the functions parameter :)
@steveokinevo
@steveokinevo 9 жыл бұрын
The this pointer is added by C++ background magic whenever the method is called looks something like this, void Hannah::printCrap(Hannah* const this) { this-> ...... } now people out there can see where it comes from.
@FeR453CA
@FeR453CA 11 жыл бұрын
you can put int num in the header and in the source file...or you can put just int in the header and int num in the source....it's the same....in the header you can name your variables but you don't have to
@TWolfguarde
@TWolfguarde 11 жыл бұрын
That's your member initialiser, from a couple of tutorials back.
@totasalam7060
@totasalam7060 10 жыл бұрын
best teacher ever
@nicksklenicka8926
@nicksklenicka8926 3 жыл бұрын
Bro... I came for a tutorial about why 'this' would be useful, and I'm left hanging
@AA-fb5fr
@AA-fb5fr 4 жыл бұрын
okay, I understand that pointer"this" is basically a pointer that points to the address of the object that called it. but why do we need it though ?
@abdullahrashid4992
@abdullahrashid4992 4 жыл бұрын
Why "this" cant be used for the simple variable in the main function?
@matiaschara7372
@matiaschara7372 10 жыл бұрын
bucky, why are you not giving a name to the int variable at the constructor prototype for the class "hannah"?
@apostolis.diamantopoulos
@apostolis.diamantopoulos 10 жыл бұрын
because you dont have to. when you write a prototype you could just let it know what type of data it will get as parameters not name these parameters. For example the default constructor prototype is Hannah(); right? you could write Hannah(void); and it would be the same!
@MalakaiPrograms
@MalakaiPrograms 5 жыл бұрын
@@apostolis.diamantopoulos thanks
@missfraser9828
@missfraser9828 2 жыл бұрын
at this point i am living for your cheap little jokes
@meghnaprakash4098
@meghnaprakash4098 4 жыл бұрын
Its bit confusing ....U didn't explain so well y u used the de-referencing
@pintoo...387
@pintoo...387 7 жыл бұрын
What is the need for member initialization here?!
@nikhilagrawal4231
@nikhilagrawal4231 6 жыл бұрын
Please explain the use of "this" in cascading
@TOOOOOTIGHT
@TOOOOOTIGHT 9 жыл бұрын
always have to restart codeblocks whenever I create a new class, so it will run. if not I get error undefiend reference to win main @16
@hwangyoujin1876
@hwangyoujin1876 12 жыл бұрын
hey... i noticed that your header files used #ifndef... well. i use visual c++ and it uses #pragma once when you add a new class to the header file instead of #ifndef by default ... which one should i use?
@jumpyjolt7015
@jumpyjolt7015 3 жыл бұрын
This gave me some errors and an error where it said invalid use of incomplete class and the name of it was rick and it also gave me a return type error about a constuctor when there was no return type on it and it was located at rick::rick(int num) and I was doing it on one file
@flow1465
@flow1465 9 жыл бұрын
I don't get it
@maddezire4397
@maddezire4397 8 жыл бұрын
+Batman it hold the address of current object!
@ClaudiuB
@ClaudiuB 7 жыл бұрын
replay it and listen carefully
@michaelcowan1761
@michaelcowan1761 7 жыл бұрын
I know this is a year old, but in case anyone else is wonder: When you create an object and use member functions on it, the compiler creates a parameter called "this". "this" is the address of whatever object you're using (a pointer) the member functions on.
@ShohamChakrabortyBatman
@ShohamChakrabortyBatman 7 жыл бұрын
It is fine, but we have the same profile picture
@Bloodication
@Bloodication 7 жыл бұрын
Just looking at this code, I instantly understood it straight away. Thank you so much man!
@mohammadbayat1635
@mohammadbayat1635 4 жыл бұрын
Bucky, I understand what this does , but how about we create multiple objects, which object this points to?
@noxtril
@noxtril 13 жыл бұрын
I'm gonna be talking to you guys about the this keyword. But before i get into that... :)
@steve122288
@steve122288 8 жыл бұрын
So the arrow member -> operator gets the object of an address... But the star in parentheses... wtf. It sounds like it somehow converts the adress to an object somehow, by "pointing" at it? but the mechanics go unexplained. I mean, this is already a pointer, so its like saying pointer of a pointer? Hmm.. he calls it dereference.... it is wierd that you have to unreference the object, in order to reference it. ... wouldnt this also mean the the arrow member selection operator also somehow dereferences?
@abrahamhuitron
@abrahamhuitron 8 жыл бұрын
Tutorial 48 & 49 were really fast, hard to follow along with.
@monkeyfire320
@monkeyfire320 11 жыл бұрын
is it necessary to "call by reference" when using the 'sfo' variable?
@rsboomboom333
@rsboomboom333 11 жыл бұрын
I know but I was asking if that's the case all the time or there's something special about this that causes it to be allowed. I'd imagine it is though.
@cabreram.4734
@cabreram.4734 5 жыл бұрын
Puting just "int" is the same as putting a variable mame that's going to be overwritten? Why didn't he use num" in the prototype
@mjdhiru
@mjdhiru 13 жыл бұрын
can somebody please ANSWER this.... why do we need the member initalizor in hannah cpp??? we only need to use a member intialor when we are using a class in anothere class right? i am confused...can anyone please help ME!!
@tofleabag
@tofleabag 8 жыл бұрын
In which cases do we use member initializers?
@DaivaDarpana
@DaivaDarpana Жыл бұрын
Why there is Hannah(int) instead of Hannah(int var_name) ??? 1min31sec
@rashidskh
@rashidskh 9 жыл бұрын
this tut. not clear honestly
@DanT-iu6oc
@DanT-iu6oc 5 жыл бұрын
yeah i didn't get it either....fuck
@madhavrathi996
@madhavrathi996 4 жыл бұрын
Yaa its bit confusing
@brkmrt2
@brkmrt2 4 жыл бұрын
i know its gonna be late but I recommend you check out Python's 'self' keyword. It explains the concept much better but I'll try my best here to explain it to you. 'this' is just a keyword used instead of the object. For example, let's create a Boat class. #include using namespace std; // Create the boat class. class Boat { public: Boat(int year, int length) : yearBuilt(year), boatLength(length) { // constructor } // Create a function that prints information about the boat. void printBoat() { // In our case, 'this' will be equal to *myBoat. cout
@vainav5794
@vainav5794 4 жыл бұрын
@@brkmrt2 i have a doubt why cant i just write boatlength instead of this->boatlength since boat lenght is a private variable hence can be used inside the entire class right ? thanks in advance for answering this question
@ad0ns371
@ad0ns371 8 жыл бұрын
Didn't you make another tutorial with the same thing :)) with pointers and objects :P ???
@beyondhelp
@beyondhelp 7 жыл бұрын
To my peeps that get confused this keyword isn't really important, actually when he call the value of h, the compiler threats it as this.h... so really it doesn't matter
@cool70200
@cool70200 8 жыл бұрын
For some reason this won't run for me with codeblocks. I keep getting an error, undefined reference to 'Hannah::printCrap()'
@VishruitKulshreshtha
@VishruitKulshreshtha 8 жыл бұрын
Are your header files correct?
@ljay0778
@ljay0778 3 жыл бұрын
If you include the Hannah.h in the Hannah.cpp you get a duplicate error, also the Hannah.cpp must be included in the main.cpp file or you get an "undefined reference" error so that in main.cpp you need the #include #include "Hannah.h" #include "Hannah.cpp" // *** this one is not shown in tutorial In the Hannah.cpp file you need: #include // Do not include the Hanna,h file here or you will get a duplicate error. using namespace std; It was very entertaining to debug it: Thank you kindly_
@brolord1288
@brolord1288 6 жыл бұрын
I make this same program in Kali Linux, and try to compile Hannah.cpp with " g++ Hannah.cpp -o Hannah " and than I get this error " /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status " . Does anyone know how to fix it ??
@HermanWillems
@HermanWillems 6 жыл бұрын
Compile main.cpp not Hannah.cpp.
@lindio95
@lindio95 10 жыл бұрын
Hannah(int) with no variable and int h with no ; ho this work?
@arbadon
@arbadon 10 жыл бұрын
If anyone is wondering.. Hannah(int) is not the default constructor so in order to run the code in this constructor an integer value is required. Since there is no def constructor : Hannah() , you will get a compiler error when you try to call Hannah ho; in your main() function. There is a way to do this by using optional parameters. Although i'm not sure they apply to constructors: Hannah(int num = 0) Now if you do not give a parameter, it will automatically set the int value to zero and run the code..
@DFsdf3443d
@DFsdf3443d 9 жыл бұрын
shouldn't h be const since we use member initialization?
@mohjam6331
@mohjam6331 9 жыл бұрын
+Peterolen Thanks for that
@Rin-qj7zt
@Rin-qj7zt 9 жыл бұрын
this is what i watch for fun.... what's wrong with me?
@Rin-qj7zt
@Rin-qj7zt 9 жыл бұрын
***** ha! i _wish._ i bet it has more to do with my frame of mind regarding complicated subjects than my level of intelligence.
@Supperesed
@Supperesed 9 жыл бұрын
+Wulframm Rolf I really need to get into that habit, otherwise I might fuck college up!
@jerfin22
@jerfin22 8 жыл бұрын
You just like programming. Nothing abnormal about that.
@ramytawfik9168
@ramytawfik9168 8 жыл бұрын
when we use the member initialzer ?
@Puffadderr
@Puffadderr 8 жыл бұрын
There are at least 5 situations when you HAVE to use member initialization list: 1) For initialization of non-static const data members 2) For initialization of reference members 3) For initialization of member objects which do not have default constructor 4) For initialization of base class members 5) When constructor’s parameter name is same as data member Or always.
@jrM5492
@jrM5492 6 жыл бұрын
@Puffadder so it falls into 5) in this video?
@iamawesomelessness
@iamawesomelessness 13 жыл бұрын
buckys tutorial is the only 1 i dont set on shuffle!
@jasonhovis2981
@jasonhovis2981 8 жыл бұрын
Welcome to the wonderful world of coding, which is debugging.
@doodies1234
@doodies1234 12 жыл бұрын
Why is it that in the header file, under public: it is Hannah(int). While in the .cpp file, it is Hannah(int num) Shouldnt the both be the same?
@warmpepsi5400
@warmpepsi5400 5 жыл бұрын
WHERE DID THE SOUND GO?
@mithunvsadananda3285
@mithunvsadananda3285 9 жыл бұрын
Can you please post some tutorials on difference between this and *this. i mean the function returning this and *this.
@ChristopherJones16
@ChristopherJones16 8 жыл бұрын
+Mithun V one has a dereference operator. Printing out this will show you a memory address.. printing out *this will show you the value stored in that memory address.
@infamousmuthu9109
@infamousmuthu9109 10 жыл бұрын
can you add the header file of a class and the actual class in the same page?
@zepix92
@zepix92 10 жыл бұрын
Yes you can.
@leejin321
@leejin321 5 жыл бұрын
but bad practice since we want to separate declaration and implementation
@tryingmybest206
@tryingmybest206 11 жыл бұрын
Check out his tutorial on composition, video number 46 - 47.
@saiabhinaybommakanti
@saiabhinaybommakanti 9 жыл бұрын
what if more than objects are being used.
@Rin-qj7zt
@Rin-qj7zt 9 жыл бұрын
so basically, you can use the This keyword instead of having to do something like ho.printcrap(ho); ... printcrap(Hannah &thing) { cout
@rsboomboom333
@rsboomboom333 11 жыл бұрын
So is that the case every single time?
@ModulusVProductions
@ModulusVProductions 8 жыл бұрын
How does this work since h is not a pointer?
@gersomfrendy1893
@gersomfrendy1893 7 жыл бұрын
go to the next episode to watch the next part.
@vetris1846
@vetris1846 10 жыл бұрын
why do we need to know this
@Dimmerr
@Dimmerr 7 жыл бұрын
Is this a meme? You used the keyword 'this'
@DebabrotBhuyan92
@DebabrotBhuyan92 10 жыл бұрын
i am getting the error "no such file or directory". Please help
@andyandrw
@andyandrw 10 жыл бұрын
Make sure they are on the same folder.
@AnonymousCuIIen
@AnonymousCuIIen 9 жыл бұрын
Andy andrew I am having the same problem and did check the box telling it to put things in the same folder. The error I'm getting reads: ||=== Build: Debug in 20150423 (compiler: GNU GCC Compiler) ===| Cullen\Documents\Programming\Cpp\BuckyVideos\20150423\hannah.cpp -o obj\Debug\hannah.o||No such file or directory| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| I've noticed that the 'hannah.o' file is not in my project folder, but I do not recall having the opportunity to create it at any stage in the tutorial. Do you know a solution to this? Side note: I keep my programming files in the My Documents\Programming directory. Could the space between 'My' and 'Documents' be causing some problems? Many thanks.
@PravinJaisawal
@PravinJaisawal 6 жыл бұрын
which one is better?
@ninehoursful
@ninehoursful 13 жыл бұрын
please make a tutorial on Copy constructors..
@Haxr-dq6wt
@Haxr-dq6wt 7 жыл бұрын
what is h: (num)
@antiHUMANDesigns
@antiHUMANDesigns 6 жыл бұрын
It's ": h(num)", right? At 5:14, line 6? It's a member initializer list. If you put a colon after the constructor, because the body of the function, then you can call the constructors of each member explicitely, separates by comma. So, "h(num)" means you create/initialize "h" using the value "num". If you don't do this, the constructor of the class will call the constructors for the members using their default constructors, instead. So always use this style of initializing your values. Otherwise you may end up calling a constructor and then assigning a value to the member separately, which is like doing it two times. struct Test { int x, y; Test() : x(123), y(456) { } };
@thehugh100
@thehugh100 13 жыл бұрын
thanks this was helpful
@hellsing357
@hellsing357 12 жыл бұрын
Very Informative thank you Sir
@mjdhiru
@mjdhiru 13 жыл бұрын
@Programmer40 ok no problem and thanks
@cprn.
@cprn. 11 жыл бұрын
Hexadecimal... J? :D
@redjr242
@redjr242 12 жыл бұрын
I'd just use the #ifndef thing because not every compiler or OS knows what #pragma once is.
@simon-yi6jv
@simon-yi6jv 3 жыл бұрын
0:55 house keeping things😂
@leeonzo4535
@leeonzo4535 2 жыл бұрын
You have the exact same syntax as sololearn what's going on
@jrM5492
@jrM5492 6 жыл бұрын
why is he using the member initializer ":" ?
@antiHUMANDesigns
@antiHUMANDesigns 6 жыл бұрын
You should always use that to initialize members, when possible. Otherwise, it's like you're first calling the constructor for a member, and then you assing a value to the member. Instead, you could call the constructor with the value that the member should have, so you're not doing two things. I think it's also required in order to be able to use "std::initializer_list" on a class, but I never use that, so I'm not sure.
@Gabriel-co6un
@Gabriel-co6un 4 жыл бұрын
Thank you so much
@Lugia1337
@Lugia1337 12 жыл бұрын
I read that in Bucky's voice.
Buckys C++ Programming Tutorials - 50 - Operator Overloading
5:35
thenewboston
Рет қаралды 554 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 849 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
you will never ask about pointers again after watching this video
8:03
I made Tetris in C, this is what I learned
15:15
Austin Larsen
Рет қаралды 24 М.
Buckys C++ Programming Tutorials - 45 - Member Initializers
8:24
thenewboston
Рет қаралды 307 М.
How different are C and C++? Can I still say C/C++?
10:25
Jacob Sorber
Рет қаралды 231 М.
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Рет қаралды 145 М.
References in C++ Explained
14:21
Caleb Curry
Рет қаралды 104 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 339 М.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 291 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН