Functions in C++

  Рет қаралды 63,543

ReelLearning

ReelLearning

Күн бұрын

Пікірлер: 27
@sothearanarith5601
@sothearanarith5601 6 жыл бұрын
Why aren't you my C++ instructor?... Thanks for this video! You make learning this so much easier than my lack luster instructor!
@ReelLearning
@ReelLearning 12 жыл бұрын
To answer your question about whether it is possible to write a function that calculates both areas, the answer is yes. You cannot return more than one value from a function, but you can pass references to vars defined in main to the function to hold the areas for the circle and square. This approach gets around the limitation of only returning one value, but violates good programming practice of only doing one conceptual action/task in a function. I recommend writing two separate functions.
@ReelLearning
@ReelLearning 12 жыл бұрын
Thanks! I'm glad you found the video useful.
@ReelLearning
@ReelLearning 12 жыл бұрын
Good programming practice would dictate not writing a function that calculates both the area of a circle AND a square. A function should only do one conceptual action/task. This makes your code better/easier to understand, reuse, maintain and test/debug. Doing a google search for "writing good functions" or "best practices for writing functions" should provide you with a lot of resources.
@RidsieD
@RidsieD 10 жыл бұрын
sir which software do you think is the best for c++???
@johnlopez5777
@johnlopez5777 5 жыл бұрын
You get a like for your patience 😄
@inquisitive871
@inquisitive871 12 жыл бұрын
Good job
@t2uan
@t2uan 12 жыл бұрын
You should have more viewers. Your videos are very descriptive and easy to follow.
@jahanzebawan1396
@jahanzebawan1396 9 жыл бұрын
fantastic, thax and keep uploading more
@AaKnSdHrAoYid
@AaKnSdHrAoYid 11 жыл бұрын
thank u vey much sir your video really held in understanding functions
@buildabs
@buildabs 9 жыл бұрын
Great videos. I have only got this far at the moment so haven't watched all videos so my suggestion I am going to give may already be in one of the further videos, but if you do decide to add more videos and it doesn't already exist can I just suggest making a video prior to this one explaining functions from a complete beginners perspective as I found this pretty confusing. This is because I didn't know or understand what functions were exactly and that functions could go before the int main etc and couldn't understand how getPosInt etc worked and how the result was outputted to the user? I hope you understand what I mean because even I have trouble understanding myself sometimes.
@plemyk
@plemyk 9 жыл бұрын
Al May Check out "Cave Of Programming" channel.He has a great series on C++ for the beginner.I highly recommend it.
@buildabs
@buildabs 9 жыл бұрын
plemyk Thanks. I did start with those videos actually but I kind of couldn't really get into it. I find this chaps videos easy to follow along with, although I might go back to the other channel at some point.
@plemyk
@plemyk 9 жыл бұрын
Al May Also try "ICT Tutorial Channel" channel,another great series on C++.
@Direwolf56
@Direwolf56 11 жыл бұрын
he is good professor
@johnparaiso3810
@johnparaiso3810 10 жыл бұрын
If you have a recursive function does the user stack keep increasing with each recursive call and then pops all the stack frames when the recursive function ends?
@OmerChoudhry
@OmerChoudhry 10 жыл бұрын
Thanks for all your help man! ^_^
@Joelych
@Joelych 8 жыл бұрын
Hello, how do you write that one message in two lines?? @19:39 Thanks in advance
@AlexEditsBadly
@AlexEditsBadly 10 жыл бұрын
Functions give me cancer.
@princebradly9165
@princebradly9165 11 жыл бұрын
u r professor
@aman.kapoor
@aman.kapoor 10 жыл бұрын
Kindly answer me the following :- 1) In the getPosInt function, if I return 0;, then my answer comes same as of return num; ...... So what is the difference to note ? Why one should use return num; instead of return 0; or return 1; or return 2; or return 99; ... you know I type any number and it returns the perfect answer. So what is it exactly ? I would be very grateful to anybody who explains me this thing. Thanks. 2) I want to tweak the code. The code taught was capable only if we put integers, then I changed it for real numbers. But I found out that if I put any character or string (due to cin it will take only first letter of string), then the cout
@torieadams198
@torieadams198 8 жыл бұрын
+Aman Kapoor I am only learning myself so this is the best answer I can give at present time: 1. Return 0 (or whatever) is for the computer to check the program has run correctly, and is only really relevant if you are using more than one program together, for example if you have one program which requests a second program to give it a response - if it returns 0, the program has worked. This could be useful (for example) for switch control. Otherwise it's just good practice to use it. 2. To use any real number, change "int" for "float" and to use any string of word change int for string; You may wish to redefine getPosInt as getPosFloat so it's mathematically accurate. You can use an if statement to return an error message - in a different (but similar) program I wrote the following line: if ((b*b) < (4*a*c) ) {cout
@foreveralone4813
@foreveralone4813 8 жыл бұрын
can anyone explain what return -1 means?
@BS-channels
@BS-channels 8 жыл бұрын
it means you will never get out of the loop
@dijuxd5536
@dijuxd5536 6 жыл бұрын
RIP Reelearning
@painsnotyourname4762
@painsnotyourname4762 6 жыл бұрын
18:25
@perfectnewstechnology3856
@perfectnewstechnology3856 8 жыл бұрын
functions really sucks
Call Stack, Scope & Lifetime of Variables
16:51
ReelLearning
Рет қаралды 49 М.
Learn C++ With Me #20 - Functions
26:14
Tech With Tim
Рет қаралды 53 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 9 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
C++ user defined functions (#15) 📬
17:14
Bro Code
Рет қаралды 37 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 827 М.
C++ user defined functions explained 📞
7:24
Bro Code
Рет қаралды 24 М.
you will never ask about pointers again after watching this video
8:03
Introduction To Classes And Objects | C++ Tutorial
11:49
Portfolio Courses
Рет қаралды 69 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН