C++ Tutorial 3 : Pointers & Functions

  Рет қаралды 70,231

Derek Banas

Derek Banas

Күн бұрын

Cheat Sheet / Transcript : goo.gl/nWDKfo
Best C++ Book : amzn.to/2FKTOpc
/ derekbanas
►► Get my New C++ Programming Bootcamp Series for $9.99 ( Expires May 6th ) : bit.ly/NewCCourse
►► Over 20 Hrs + 52 Videos + Quizzes + Graded Assignments + New Videos Every Week
As we continue to learn C++ through problem solving we cover Functions, Pointers, Local Variables, how to create a range function and solve a bunch of problems.
I hope you find using pointers to be a breeze after this tutorial. Please share your alternative problem solutions.

Пікірлер: 206
@derekbanas
@derekbanas 6 жыл бұрын
KZbin notified me that they will no longer send notifications, when I make a new video, unless subscribers click the Bell button. I hope everyone is finding the new C++ tutorial useful. Arduino programming will start soon.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'll see what I can do
@redvenom9304
@redvenom9304 6 жыл бұрын
Derek Banas Thank you, Derek, for this C++ tutorial! Can you please include data structures?
@tacca4720
@tacca4720 6 жыл бұрын
Yes, enjoying them greatly; been a long time since I did any c / c++... now my kids are asking questions, I am discovering how much I have forgotten :/
@sirturnables
@sirturnables 6 жыл бұрын
Please, do I need to know electronics to follow your Arduino tutorials?
@santhoshs4891
@santhoshs4891 5 жыл бұрын
printf is not declared in the scope help
@bajatg
@bajatg 6 жыл бұрын
30:55 std::vector Range(int sVal, int eVal, int iVal) { std::vector range; for (int i = sVal; i < eVal; i += iVal) range.push_back(i); return range; }
@Evildragonfirez
@Evildragonfirez 6 жыл бұрын
This series should end up in the library of congress. Your videos, are incredible, I am eternally grateful.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for the nice compliment :)
@ryantripi6647
@ryantripi6647 6 жыл бұрын
Another great video, especially since pointers have always been my weak point (stayed home sick on the day we covered them in class). The first problem I got a bit of a different solution as I pass my vector in by reference to be altered in the function, but I really liked your way in how you just used the function in the assignment of the vector, thus ridding the need to pass it in at all.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm very happy you found it useful
@edgarhakobyan8429
@edgarhakobyan8429 2 жыл бұрын
I just want to thank you for making such informative videos. I love the fast paced environment. I learned some of the concepts from school but didnt understand alot of the things. And unlike other youtube videos that go over the stuff very slowly and make it boring, your videos are fast paced and good for those who know a little bit of C++ but need refreshment. From the first 3 tutorials i learned more in 2 hours than in 3 weeks in school. Thank you
@derekbanas
@derekbanas 2 жыл бұрын
Thank you for taking the time to say I helped :) I appreciate that! I wish you all the best
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
When you define a function prototype, you don't need to give parameters names. You only need to specify the return type, the name, and the types of the parameters. You can turn double addNumbers(double num1, double num2); into double addNumbers(double, double);. You also don't need to declare if variables are constant here either; you only have to declare constants when you are actually defining the function. The compiler actually discards your variable names in your function prototypes as you can rename your variables something else in your actual function definition. You can only use the names from the prototype if you also call them that in your definition. I'm sure Derek knows this, but this is more for everyone else learning C++! Less typing for everyone!
@derekbanas
@derekbanas 6 жыл бұрын
Yes I know. I just find the code easier to read when I use the names in the prototypes
@victormponcec
@victormponcec 4 жыл бұрын
std::vector range (int start, int max, int inc){ std::vector vector; for (;start < max; start += inc){ vector.push_back (start); } return vector; }
@victormponcec
@victormponcec 4 жыл бұрын
//*start
@akshaytati
@akshaytati 6 жыл бұрын
Summer holidays are coming in 5 days Gonna complete blender, C# and C++ tutorial series of yours! Keep up the good work!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I hope you enjoy them
@jihedjaouabi7623
@jihedjaouabi7623 6 жыл бұрын
OMG, I swear I was just watching your 1H C++ Tut, at minute 43, when you talked about pointers, I was like "errgh this is not so well explained..".. And then this notification showed up!! :O
@derekbanas
@derekbanas 6 жыл бұрын
Awesome I'm glad I did a better job the second time :)
@revenevan11
@revenevan11 3 жыл бұрын
Thank you so much for this tutorial! Because I was fondly remembering a similar function built in to MATLAB, I wrote my Range function to work with doubles so it could do more than just integers. Here it is: vector Range(double dSV, double dEV, double dInc) { vector dvRet; for (double c = dSV; c
@derekbanas
@derekbanas 3 жыл бұрын
I'm happy you liked it :) Thank you for sharing
@FritsvanDoorn
@FritsvanDoorn 6 жыл бұрын
Nothing to add. You give me something to think about and I got a lot of ideas to work out. Thank you !!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm glad it was interesting
@akshayelangovan7764
@akshayelangovan7764 Жыл бұрын
I’m 26 years old and finally understood how to use pointers. Life milestone
@entiretwix1480
@entiretwix1480 5 жыл бұрын
I just did std::vector Range(int init, int max, int incriment) { std::vector temp( ((max - init)/incriment)+1) ; for (int i = 0; i < temp.size(); ++i) { temp[i] = init + (incriment*i); } return temp; } instead of a while loop why not use a for-loop as they are meant for incrementing, I'm actually curious if there is a reason.
@ledzeppeman
@ledzeppeman 6 жыл бұрын
Hey Derek, long time fan. These videos are awesome. They really help me learn at a faster pace. I'd like to offer a super tiny suggestion. I listen to your videos on open-back headphones, so the sound stage is particularly pronounced, and it sounds like you're sitting off to my right. Now I really appreciate stereo sound, but the uneven balance is a bit dissociating. Perhaps this wouldn't be the case if you turned your microphone so that it symmetrically faces you while you record. A side note, at first, I wasn't totally sure, but I ripped the audio from this video and looked at it in a music editing software. The right channel is without a doubt louder.
@derekbanas
@derekbanas 6 жыл бұрын
Sorry about that and thank you for telling me it is distracting. I'm going to look into if I can find a floating mount for my mic. It is to the side because it blocks my view of the screen when I record.
@fortifiedconcept4260
@fortifiedconcept4260 6 жыл бұрын
You are the best.I have download most of your tutorials and i am waiting for more everyday!!!Thank you very much!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Many more are coming
@brodoswaggins5387
@brodoswaggins5387 4 жыл бұрын
These are excellent explanations. thanks so much!
@hitarthpanchal1479
@hitarthpanchal1479 4 жыл бұрын
1. How to intitialize vector with all zeros or ones? 2. If I initialize vector(10), then enter values using push_back, will this work and if yes at which index the value will be stored?
@monolinepl-monocykl8180
@monolinepl-monocykl8180 5 жыл бұрын
Hi everyone. I am wondering is there any difference between that from video: void DoubleArray(int* arr, int size) { for(int i=0;i
@calebjohnstone4856
@calebjohnstone4856 5 жыл бұрын
There is no difference. The 2 forms of referring to the i-th element in an array will both work. i.e. arr[i] will get the same result as using *(arr+i) Therefore it follows that arr[i] *= 2 and *(arr+i) *= 2 will both do the same task. This is probably the logic you used when asking this question.
@bidaarle
@bidaarle 6 жыл бұрын
#include #include std::vector range(int min, int max); int main(){ std::vectormyrange = range(1,10); for(int y : myrange) std::cout
@TravelingMooseMedia
@TravelingMooseMedia 4 жыл бұрын
I absolutely love this series
@derekbanas
@derekbanas 4 жыл бұрын
Thank you :)
@peacelover2517
@peacelover2517 6 жыл бұрын
Just saw the notification and I am here.. Thank you, Derek. :)
@derekbanas
@derekbanas 6 жыл бұрын
Yeah, I'm glad the bell is working and thank you for clicking it :)
@jcq2505
@jcq2505 6 жыл бұрын
YUPPP : "DEREK BANAS uploaded...DEREK BANAS uploaded...DEREK.BANAS uploaded"
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy you are enjoying the videos :)
@jcq2505
@jcq2505 6 жыл бұрын
Derek Banas we are happy you paint our world
@vivekpanchagnula815
@vivekpanchagnula815 5 жыл бұрын
I thought that you meant simple interest in the last bit and was thoroughly confused as to why I'd use the range function for that.
@xavierlesperance6156
@xavierlesperance6156 3 жыл бұрын
Id like to start by saying the videos are great thanks you very much for making them! I had a question at around 12:30 you have the user input two numbers, I decided to just change your code up a little to see how it would work and came up with this user input method: std::cout dbNum2; ^ this works without a hitch v this does not for some reason: std::cout > dbNum1; std::cout
@vegansynths7757
@vegansynths7757 4 жыл бұрын
the latter part was tough to grasp. Gonna keep working at it. One thing I noted; when going back to an address previously called, only the last 3 digits are the same address. Why are the other numbers changed? does the address change? confused me.
@up4life108
@up4life108 6 жыл бұрын
Do you have a job besides youtube or are you doing youtube fulltime? Your tutorials seem to be extremly well prepared.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :) Yes I run online stores, make mobile apps and other security stuff. I'm a pretty lucky guy
@up4life108
@up4life108 6 жыл бұрын
Nice! Hopefully im going to be where you are in life at some point!
@derekbanas
@derekbanas 6 жыл бұрын
Keep at it and you will. I have had some terrible lows. I suffered from some serious health issues and things got bad. At one point in my life I was living in the ghetto and surviving on just rice and beans. I took what was considered to be a terrible job, but because I hustled a higher up noticed me and promoted me. You never know who may be watching. That got me back on my feet. I had a bunch of other lows after that, but at some point I realized I needed to start my own business to be happy. Thankfully my Wife was willing to put up with some struggles for about 3 years, but then everything fell into place because of a combination of hard work and luck. The only people that fail are those that give up :)
@up4life108
@up4life108 6 жыл бұрын
Really interressting to get some background to the person making theese videos ! Imma keep trying
@derekbanas
@derekbanas 6 жыл бұрын
We all have bad times in life. I learned more from them then any good times for sure. I'm happy that they occurred and that I made it through.
@Imp0ssibleBG
@Imp0ssibleBG 6 жыл бұрын
Why and when do we need/ have to use pointers? I really understand how they work but cannot see their practical use. EDIT 1: Is it like faster when we directly change the value of an address rather than changing the actual variable's value Your tutorials are awesome!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Pointers were originally useful because they allowed for the creation of arrays and strings. You could allocate memory blocks large enough for both. They can also be used to take and return memory which allows your programs to run on much less memory and avoid creating duplicate data.
@Imp0ssibleBG
@Imp0ssibleBG 6 жыл бұрын
Derek Banas Thank you! So for example instead of passing a object which contains a lot of data, we will just point to it with a pointer?
@derekbanas
@derekbanas 6 жыл бұрын
Exactly, that saves from making duplicate data in memory
@BlackMambo5
@BlackMambo5 6 жыл бұрын
Data Structures primarily rely on pointers. Basically you can't create a Linked List or a BST or a HashTable, etc. if you can't have pointers or don't know how to use them. As for your remark of passing an 'object', you can simply use pass-by-reference instead of passing a pointer to said object. Use-cases like dynamic memory allocation is where pointers are needed. But always make sure anything you create(dynamically allocate memory for) in the heap is deleted/freed once its use is done, otherwise you have memory leaks galore.
@kori4386
@kori4386 6 жыл бұрын
when i programmed C in univercity they told me to use pointers because they are allot faster. because you only have to change the meonry address not the variable
@2271masoud
@2271masoud 6 жыл бұрын
Thanks for the tutorial Derek
@derekbanas
@derekbanas 6 жыл бұрын
It was my pleasure to make it :)
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
I think the conventions with functions is that the first word is not capitalized and you capitalize all of the words of the names of things like unions, structs, classes, etc.: the more "structure" style things. This was how I was taught; am I wrong in this assumption?
@derekbanas
@derekbanas 6 жыл бұрын
It doesn't really matter. I capitalize functions to make them stand out from variables, but there is no definitive right or wrong way of doing these things IMO
@oneinabillion654
@oneinabillion654 3 жыл бұрын
Hi sir, im a beginner in C++ and have knowledge on C. Regarding this line: for(auto y:myVec) std::cout
@extazzyyes7672
@extazzyyes7672 6 жыл бұрын
Great series thus far. Hopefully it'll be enough to prepare me for a module in C++ at uni after the summer holidays :).
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I plan on covering way more then is covered in most C++ courses
@extazzyyes7672
@extazzyyes7672 6 жыл бұрын
That's even better :). And I see you weren't bluffing when you said you read all the comments hah. :p
@zakariarizvi8003
@zakariarizvi8003 6 жыл бұрын
Hi Derek, You're too good man. Just wanted to ask when is your arduino tutorial coming. Thanks.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :) I'll start making Arduino tutorials with the C++ tutorials right around the time in which I've covered the core C++ language. Very soon
@SuperJonalicious
@SuperJonalicious 6 жыл бұрын
Derek, it would be super awesome if you did an Elastic Search tutorial
@derekbanas
@derekbanas 6 жыл бұрын
Sorry I don't have a subscription
@lldazzlingdoodlesll6376
@lldazzlingdoodlesll6376 3 жыл бұрын
Hey Derek! while returning the vector for the range function, we are returning by value, right? Can we pass a pointer to a vector to the Range function and have the function populate the vector that we passed it?
@r72rock
@r72rock 6 жыл бұрын
Heads up to those of you who are using VS Code on windows, and you're trying to use CodeRunner -- You'll get an error if you compile the first bit of code that Derek runs. iota(), begin(), and end() are a part of C++11, so you have to configure code runner to use C++11. Just go to your VS Code settings (File -> Preferences -> Settings) and add this to your settings: "code-runner.executorMap": { "cpp": "cd $dir && g++ -std=c++11 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" }
@publicstaticvoid3224
@publicstaticvoid3224 6 жыл бұрын
Thanks for making this Derek!
@derekbanas
@derekbanas 6 жыл бұрын
It is my pleasure to help :)
@MrLulu2671
@MrLulu2671 6 жыл бұрын
Thank you so much for the great tutorial. I learnt all my JAVA code from you. I sacked in astray not understanding the code you explained, but i found that your videos reallyy gave me some foundation knowledge and practical coding which makes it easier to relavant topics i am going to learn, love that fast pace you brought to the tutorial and better than most JAVA tutorial in HINDI i think. However, I found that i can't run your cheat sheet on the JAVA tutorial 38 talking about the JDBC swing GUI. Could you please spend a few minutes and review the code? Thank you so much Man!! Love that quick pace style, looking forward for the next video.
@ravishankarsatheesh1901
@ravishankarsatheesh1901 6 жыл бұрын
Your videos are awesome. This one helped a lot Thanks
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :)
@matsn0w
@matsn0w 6 жыл бұрын
You rock mate!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :) I try to do my best
@MrManojKumarPrasad
@MrManojKumarPrasad 5 жыл бұрын
Hey Derek, I'm currently reading "C++ Primer" so I wanted to ask should I read the book in your description or continue reading the one I'm reading?
@derekbanas
@derekbanas 5 жыл бұрын
C++ Primer is also very good. Stick with it if you like it
@aymanbelhaj2853
@aymanbelhaj2853 4 жыл бұрын
thanks a lot for the tutorial can you point to the video you mentioned in 18:44 about hexadecimal
@nokap2695
@nokap2695 3 жыл бұрын
very helpful video!
@derekbanas
@derekbanas 3 жыл бұрын
Thank you :) I'm happy you enjoyed it
@richmancatabona2345
@richmancatabona2345 5 жыл бұрын
Im confused. Why the value of the memory adress is 6octets long? (0x7fff5f692a48). I thought size of adress matches the system architecture. E.g.If 32bit program, memory size is 32 bit long. But there is no 24bit architecture afaik. Please help me clarify this sir. TY in advance.
@leoniaklebanov2502
@leoniaklebanov2502 5 жыл бұрын
Excellent video, thank you!!!!!
@derekbanas
@derekbanas 5 жыл бұрын
Thank you :)
@leoniaklebanov2502
@leoniaklebanov2502 5 жыл бұрын
Derek Banas I use you tutorial for return to hi tech; and it contribute me undefined value; also I learned English watched you video tutorials and don’t feel panic when I watch any video on KZbin; thank you so math!!!!!
@HalValla01
@HalValla01 5 жыл бұрын
Why do you use " " in stead of endl?
@byteaesx1373
@byteaesx1373 6 жыл бұрын
The book you suggest about C++ is better than the Professional C++ from (Wrox)? Many thanks for the series. I pretty sure you'll be a reference in years to come. Waiting for the C# long course with examples...
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :) Here is my C# course kzbin.info/www/bejne/ZqGTe398j89leZo
@byteaesx1373
@byteaesx1373 6 жыл бұрын
Respect.
@sandeepvk
@sandeepvk 6 жыл бұрын
Thanks Derek.The C++ paradigm seems hard compared to Javascript / Python. Could you please me why do we need Arduino ?
@derekbanas
@derekbanas 6 жыл бұрын
You'll get it with a little practice. I wanted to also cover Arduino because a version of C++ is used to program Arduinos. It provides a great way to get directly to low level hardware programming. I also like Arduino because I would have never been able to become a consultant without.
@buffaloSoldier519
@buffaloSoldier519 6 жыл бұрын
Could you show us how to actually program the micro controller using its schematics and Visual Studios rather their own software?
@derekbanas
@derekbanas 6 жыл бұрын
I'm going to program Arduino with Visual Studio Code
@channelnumber52
@channelnumber52 6 жыл бұрын
Arduino is how I got my start programming. I think it's cool because you get to make something tangible with your code. It's easier to have arduino read a sensor, and blink a light, than it is to get a desktop application with a GUI going. The arduino was very encouraging for me.
@sirturnables
@sirturnables 6 жыл бұрын
B.E.A.utiful!!!!!!!
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
Is there a reason why you used std::begin() and std::end() to make iterator objects out of the vector instead of just doing myVec.begin() or myVec.end()? I finished a data structures class last semester which was taught in C++ and I am going through these videos to learn more about C++ that I didn't know, and we always used object.begin() or object.end() to get an iterator object. I didn't even know that std::begin() and std::end() existed, so what exactly is the difference between these functions and object.begin() or object.end()? Is there a reason to use one over the other; do they do different things?
@derekbanas
@derekbanas 6 жыл бұрын
Both operate in the same ways. In my tutorials I like to show things being done in numerous ways, so that when you see them in other peoples code it will be understandable
@caddydz
@caddydz 6 жыл бұрын
Hey Derek I'm in my 3 and a half years of self learning phase Do you recommend or go against learning multiple languages?
@derekbanas
@derekbanas 6 жыл бұрын
I think it is best to learn 1 core language very well. After that you'll more then likely have to learn others. Every single day I use JavaScript, PHP, C#, and SQL. A few times a week I use Java, C++ and Python. I am however a consultant, so I don't work on just 1 project in a team.
@caddydz
@caddydz 6 жыл бұрын
Got it, thanks you so much I just want to build a cross platform service where I have PHP on the backend So am learning other languages to create some sort of native client apps that consumes the backend
@vyasramankulangara8804
@vyasramankulangara8804 6 жыл бұрын
Please do data structures and algorithm in C++
@derekbanas
@derekbanas 6 жыл бұрын
Those videos are coming
@vyasramankulangara8804
@vyasramankulangara8804 6 жыл бұрын
Thank you
@sulaymontajudeen8030
@sulaymontajudeen8030 6 жыл бұрын
Hi Darek, thanks very much for awesome contents, please I need a little help, I tried running the same code for AddNumbers function on VS code after following your set up instructions but it told me that "Cannot edit in read-only editor " please how do I solve that. Thanks in advance.
@hou3455
@hou3455 5 жыл бұрын
I find a little bit superficial and confusing to use a vector instead of a loop to loop from 1 to 10. :-) :-) :-) But I understand why it was asked to make usage of the vector in the contect of the exercise.
@derekbanas
@derekbanas 5 жыл бұрын
Sorry about that. I was looking to demonstrate an interesting example
@bananacraft69
@bananacraft69 Жыл бұрын
step size is irrelevant std::vector range(int a, int b) { std::vector vRange; for (int i = a; i < b; i++){ vRange.push_back(i); } return vRange; } Also, for convenience: void print(std::string msg = "", std::string end = " ") { std::cout
@sriramiyer9840
@sriramiyer9840 4 жыл бұрын
Why does getline() work without std:: in your code but gives error on my system. I'm using gnu gcc compiler
@pjetr0boy338
@pjetr0boy338 5 жыл бұрын
Hi Derek, you made very good C++ courses. I don´t speak English very good. Please, can you add subtitles? I'm using automatic translation to my language. Thank you so much. Sorry for my english :)
@lliliiliillliliiliili5180
@lliliiliillliliiliili5180 6 жыл бұрын
Gonna watch this as soon as I get home
@derekbanas
@derekbanas 6 жыл бұрын
I hope you enjoy it :)
@meiz1795
@meiz1795 6 жыл бұрын
In the last problem, why did you use Range function if that task could be done on many different, and easier, ways?
@derekbanas
@derekbanas 6 жыл бұрын
I like to explore numerous ways of doing things
@stuartlightfoot1729
@stuartlightfoot1729 5 жыл бұрын
It's almost perfect; lacking subtitles. Subtitles would make this amazing for different audiences.
@AshokKumar-bi1jp
@AshokKumar-bi1jp 5 жыл бұрын
Hi Derek please do a tutorial seriea on C programming and data structures
@derekbanas
@derekbanas 5 жыл бұрын
I'll see what I can do
@yssacnton95
@yssacnton95 6 жыл бұрын
Really cool!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@brandtize
@brandtize 6 жыл бұрын
great video.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@Sejiko
@Sejiko 6 жыл бұрын
Hey can you make a video about getting some other libraries to Netbeans and Cpp such as (Cinder, SDL, OpenGl ...) so we can do something with Graphics?
@derekbanas
@derekbanas 6 жыл бұрын
I'll cover that soon
@hansrajrami
@hansrajrami 6 жыл бұрын
Hello, please cover algorithm using c++ as well With different algorithm techniques like greedy algorithm, branch and bound algorithms, devide and conquer algorithm,dynamic algorithm Please please..
@derekbanas
@derekbanas 6 жыл бұрын
I'll be covering those soon
@alexanderbrown1178
@alexanderbrown1178 6 жыл бұрын
Great video Derek! Really enjoying this playlist. I'm confused though: I get linting and compile errors if I don't use the reference operator to assign age to pAge, yet when I pass arr into DoubleArray I don't need the reference operator. Why?
@alexanderbrown1178
@alexanderbrown1178 6 жыл бұрын
Interesting... seems to be something to do with the fact it's an array. If I store age as an int array I have to remove the reference operator...
@alexanderbrown1178
@alexanderbrown1178 6 жыл бұрын
Just realised I totally missed the bit where you said you don't need to use the reference operator with arrays! Are there any other data types where the reference operator isn't needed? Vectors, maybe?
@derekbanas
@derekbanas 6 жыл бұрын
Sorry I didn't explain that better. Passing a vector reference to a function works like this void SomeFunc(vector &vect) { Do stuff with vector } int main(){ vector vect; SomeFunc(vect); }
@user-cw3nb8rc9e
@user-cw3nb8rc9e 4 жыл бұрын
1:51 Wasn't it better to declare the "i" as size_t instead of int? that vector size returns size_t type value
@ammaralomary7274
@ammaralomary7274 6 жыл бұрын
Your final problem is rather confusing. The Range function here does not really do anything since you don't use the variable y at all in your interest calculation. you might as well have used a normal for loop in this particular case.
@darkchocolate3390
@darkchocolate3390 6 жыл бұрын
5:55 *gulp*
@davidpereira5303
@davidpereira5303 6 жыл бұрын
I'm running C++ on Eclipse. I'm having problems with "iota", I have an error message saying "it could not be resolved". Any suggestions? Thank you
@derekbanas
@derekbanas 6 жыл бұрын
www.eclipse.org/forums/index.php/t/636348/
@davidpereira5303
@davidpereira5303 6 жыл бұрын
Thank you ! Looking forward for the next videos, started learning C# with you, and now C++ . Very very helpful tutorials
@LadolMark
@LadolMark 6 жыл бұрын
good
@spooky_zen
@spooky_zen 6 жыл бұрын
great tutorial i final realized what set notation is lol
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm glad it helped
@Typrograms2
@Typrograms2 6 жыл бұрын
Uh... I'm confused. I have the following code: (4:54 time reference - self attempt #1) for(auto y : myVec) std::cout
@derekbanas
@derekbanas 6 жыл бұрын
I see the problem. y is assigned the next value in the vector. y isn't the index address like it is in a standard for loop. replace myVec[y] with just y and it should work.
@Typrograms2
@Typrograms2 6 жыл бұрын
I.. I just have no clue. I (maybe as you've noticed) keep replying and deleting my comments because I think I have the solution but then it just doesn't make sense. I've had issues beyond me. The JavaScript conversion test had similar results, but not exact. I know 'y' definitely was not the problem as I used std::cout to print out the value of 'y' and it was always the correct index number. myVec[y] had some RANDOM results, even though the values were fine. 'void countandlog(std::vector vec)'
@Roblbaxx
@Roblbaxx 6 жыл бұрын
Thx
@derekbanas
@derekbanas 6 жыл бұрын
Happy to help :)
@Roblbaxx
@Roblbaxx 6 жыл бұрын
You are the best
@adri2350
@adri2350 4 жыл бұрын
It's better to initialize pointer with nullptr value because NULL is a #define NULL 0
@johnsilver5783
@johnsilver5783 6 жыл бұрын
Derek, cover OpenGL please
@derekbanas
@derekbanas 6 жыл бұрын
I'll see what I can do
@johnsilver5783
@johnsilver5783 6 жыл бұрын
I need it!
@Adam-cn5ib
@Adam-cn5ib 6 жыл бұрын
27:31. Here is my take on the problem, i haven't watched the solution at the time of writing this. Ignore all the includes. Can anyone give opinion? #include #include #include #include #include #include #include using namespace std; int incrementFunc(int startingValue, int endingValue, int incrementAmount); int main() { incrementFunc(0,100,12); } int incrementFunc(int startingValue, int endingValue, int incrementAmount) { vector arr(endingValue/incrementAmount); for(int i = startingValue; i < arr.size() + 1; ++i) { arr[i] = incrementAmount * i; cout
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for sharing :)
@felixkimutai8478
@felixkimutai8478 6 жыл бұрын
What's iota ? I am using Microsoft visual studio ide but it's not working. I have also tried with codeblocks but I still get error "identifier "iota" is not defined "
@felixkimutai8478
@felixkimutai8478 6 жыл бұрын
got it, thanks
@trinitygod863
@trinitygod863 6 жыл бұрын
Im using VS too and getting the same error how did you fix it?
@kijiyakiace3616
@kijiyakiace3616 5 жыл бұрын
#include
@ttdMrGrin
@ttdMrGrin 5 жыл бұрын
Hello, Im using Visual Studio. When printing out a memory adress I get something like this > 008FF75C, (8 signs) instead of a hexdecimal number. I cant figure out why ... ( In Netbeans i get something like this > 0x61ff18, looks more like it but still a very short number (8 signs)). Anyone who knows whats going on?=)
@ttdMrGrin
@ttdMrGrin 5 жыл бұрын
@Peterolen cheers, though it baffels me that Visual Studio never show it with 0x while both CodeBlocks and NetBeans both print out 0x (is it so that Visual Studio have a different standard for showing hex numbers?) 00 instead of 0x and if so, why?=)
@ttdMrGrin
@ttdMrGrin 5 жыл бұрын
​@Peterolen Thanks again for the explenation, I really appreciate it, Im all new into this and really disslike not knowing the why =)
@lowochi
@lowochi 6 жыл бұрын
Hi Derek! When I tried to type in: std::iota(std::begin(myVec), std::end(myVec), 0); I got an error, it says it expects 3 arguments and only 2 are provided. I'm programming in Visual Studio and included the following: #include #include #include #include #include #include Do you know what caused the error?
@derekbanas
@derekbanas 6 жыл бұрын
That's strange. Maybe the newline is causing that, but it shouldn't
@jasonchvat1071
@jasonchvat1071 6 жыл бұрын
Maybe try myVec.begin(), myVec.end(),0
@vegardpig8634
@vegardpig8634 6 жыл бұрын
Is there a language you can’t write in?
@nuclearnyanboi
@nuclearnyanboi 6 жыл бұрын
I have a test tomorrow :D
@zkfdsldfjsdjfl1
@zkfdsldfjsdjfl1 6 жыл бұрын
how come you are not using namespace std is it just a preference thing
@derekbanas
@derekbanas 6 жыл бұрын
It can cause conflicts so I never use it. For a short silly program it is fine to use though
@zkfdsldfjsdjfl1
@zkfdsldfjsdjfl1 6 жыл бұрын
what kind of problem
@devilmanscott
@devilmanscott 6 жыл бұрын
As your program grows and you increase the number of namespaces, also bringing in third party packages increases the chance of conflicts happening, so it's far better not to use it, also every decent C++ programmer will tell you not to use it as it goes against best practices. The rule it pretty strong across all languages, don't ever pollute the global namespace.
@sirturnables
@sirturnables 6 жыл бұрын
Derek, I think your compound interest program is faulty. 1000 investment at the rate of 8% should give 1800 after 10 years. Mine was right though!!!
@derekbanas
@derekbanas 6 жыл бұрын
Sorry if I made a mistake
@sirturnables
@sirturnables 6 жыл бұрын
Sorry, I realized I was the one that didn't understand how compounding works. Yours is correct. What I was doing was calculate 8% on the initial investment and adding it 10 times to the investment. However, every year 8% has to be recalculated on the new investment, just like you did. I calculated the yearly earning outside the loop instead of inside.
@kressckerl
@kressckerl 5 жыл бұрын
Are you from Texas?😄
@derekbanas
@derekbanas 5 жыл бұрын
Pennsylvania
@kressckerl
@kressckerl 5 жыл бұрын
@@derekbanas ah okay great tutorial😁
@No_handle-_-
@No_handle-_- 4 жыл бұрын
Not NULL it should be nullptr for initialization of pointers
@Tiara48z
@Tiara48z 6 жыл бұрын
Does any one know how to fix: cannot open source file “iostream”, in VS Code. Thank you
@derekbanas
@derekbanas 6 жыл бұрын
Check the solutions in the 2nd answer here stackoverflow.com/questions/11713842/visual-c-cant-open-include-file-iostream
@Tiara48z
@Tiara48z 6 жыл бұрын
Derek Banas thank you so much.
@rameshkumatagi8098
@rameshkumatagi8098 4 жыл бұрын
using range function for compound interest problem looks silly. Loop variable y was never used in calculation.
@drfpslegend4149
@drfpslegend4149 5 жыл бұрын
what is iota? 1:23 and no explanation.
@derekbanas
@derekbanas 5 жыл бұрын
With std::iota(std::begin(myVec), std::end(myVec), 0) we are saying we want to take the vector myVec and starting at the beginning of myVec we want to place a 0 and then place incrementing values in every other index until will reach the end of the vector
@techwithjordan
@techwithjordan 2 жыл бұрын
I’m going to be a pointer for Halloween
@derekbanas
@derekbanas 2 жыл бұрын
That's funny :D
@Shpendulum
@Shpendulum 6 жыл бұрын
printf() is ten times more eye pleasing for me compared to that cout abomination.
@derekbanas
@derekbanas 6 жыл бұрын
I use both regularly
@CrazyBrotherTime
@CrazyBrotherTime 6 жыл бұрын
But what's the point of them though? :)
@derekbanas
@derekbanas 6 жыл бұрын
Point of what?
@__thytran
@__thytran 5 жыл бұрын
Thanks a lot but I can't use std::iota C:\Users\augus\Documents\Cpp\practice\main.cpp|32|error: 'iota' is not a member of 'std'|
@cawley345
@cawley345 6 жыл бұрын
man I have to write a program to solve a heat transfer problem and have no idea what to do
@changeluhia
@changeluhia 6 жыл бұрын
problems not easy. I'm worried. haha
@derekbanas
@derekbanas 6 жыл бұрын
Keep at it and it will eventually make sense
@Alphabet_-_
@Alphabet_-_ 5 жыл бұрын
@sergioavila2720
@sergioavila2720 6 жыл бұрын
i just use the terminal in Linux
@derekbanas
@derekbanas 6 жыл бұрын
That's fine
@nadrogiranihibiskus5186
@nadrogiranihibiskus5186 6 жыл бұрын
what about this level of knowledge? will you cover all of that?:D /watch?v=JPlAqPb4izs
@derekbanas
@derekbanas 6 жыл бұрын
I'll explain C++ so that you'll be able to understand that code yes
@nadrogiranihibiskus5186
@nadrogiranihibiskus5186 6 жыл бұрын
guy in that video says its simple code... is this something a 1 year of c++ programmer can do?
@derekbanas
@derekbanas 6 жыл бұрын
Yes definitely. C++ can look complex if you don't know what the jargon terms mean. It is pretty easy to pick up with a little practice
C++ Tutorial 4 : Exception Handling & Looping
25:45
Derek Banas
Рет қаралды 51 М.
C++ Tutorial 11 : Polymorphism
18:48
Derek Banas
Рет қаралды 76 М.
Хасанның өзі эфирге шықты! “Қылмыстық топқа қатысым жоқ” дейді. Талғарда не болды? Халық сене ме?
09:25
Демократиялы Қазақстан / Демократический Казахстан
Рет қаралды 347 М.
This dad wins Halloween! 🎃💀
01:00
Justin Flom
Рет қаралды 12 МЛН
Sigma baby, you've conquered soap! 😲😮‍💨 LeoNata family #shorts
00:37
SISTER EXPOSED MY MAGIC @Whoispelagheya
00:45
MasomkaMagic
Рет қаралды 13 МЛН
C++ Tutorial 13 : Advanced Functions
18:27
Derek Banas
Рет қаралды 67 М.
C++ Tutorial 2 : Conditionals, Arrays, Vectors, Strings, Loops
32:14
C++ Tutorial 8 : Recursion Algorithms & Overloaded Functions
31:43
Anxiety Wars: Existentialism vs Absurdism
14:10
mystiverse
Рет қаралды 464
C++ Tutorial 12 : Operator Overloading & File I/O
28:30
Derek Banas
Рет қаралды 35 М.
C++ Tutorial 10 : Object Oriented Programming
40:25
Derek Banas
Рет қаралды 241 М.
C++ Tutorial 14 : Templates & Iterators
22:13
Derek Banas
Рет қаралды 74 М.
Хасанның өзі эфирге шықты! “Қылмыстық топқа қатысым жоқ” дейді. Талғарда не болды? Халық сене ме?
09:25
Демократиялы Қазақстан / Демократический Казахстан
Рет қаралды 347 М.