Buckys C++ Programming Tutorials – 63 – More Exceptions Examples

Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –






46 responses to “Buckys C++ Programming Tutorials – 63 – More Exceptions Examples”

  1. bismal majeed Avatar

    nice work keep it up..:)

  2. Yu Zhao Avatar

    This wasn't that difficult

  3. Sunny shah Avatar

    Gotta catch em All Pokemon!

  4. Shafkat Kabir Avatar

    I have tried a lot but haven't been successful. I have been trying for a long time to actually build a calculator. A calculator as in a calculator where u can add, subtract, multiply, divide. This much is enough. But I haven't been able to do this. I tried using classes, different functions but without success. And a bigger problem is that I can't use the "cin >> " thingy in classes yet, as in I tried to use it with the class objects but it shows error every time, otherwise I can use it. Someone help.

  5. Lynette Mojica Avatar

    Yes I do want to know object exception handling.

  6. Jack Claudiu Avatar

    it should have more sense like this: if (num2 == 0|| num1==0){ ..bla bla yati yati yati 😛

  7. TerpGaming Avatar

    So if you were to throw several int errors with different corresponding messages, how do you catch them seperately? Say you also wanted to check for a negative number as well as zero, and have it display a new message for negative numbers. How would you do this? Also, thank you for this videos. They are so much more helpful than my teacher :/

  8. Romzik Keep Calm and Carry On Avatar

    LoL cool!
    like the moment:
    "let's go ahead and say that we have an idiot that's gonna you know neve knows how to use calculator and is going to try to divide by 0"
    That's really funy moment!
    Like sorta videos!!!

  9. FingersBlazin Avatar

    I think this was the first program I've written that actually does something meaningful. Now I make a million dollars with my calculator

  10. eggo Avatar

    cool huh, pretty?

  11. ThePaypay88 Avatar

    so what happens if i had to include two error types for int data type.like if you divide by 0 you get different catch but if you divide by -1 it tells you another different message . how to do that? we use catch(int x) which would take both 0 and -1 but i want different catch functions(?)

  12. rem brandt Avatar

    can you catch an auto type?

  13. Kunal Sharma Avatar

    If i write throw "ERROR";
    what to pass in catch(?????)

  14. Darcy Tellier Avatar

    the math gods will not allow it .

  15. Rustman Avatar

    The return of "pretty cool huh"

  16. cronnostiger64 Avatar


  17. Mott Bot Avatar

    Well you could divide by zero in theory, this is why we have limits 😛

  18. amanuel2 Avatar

    Or you can actually create exceptions just like the … but this time you can actually give it a variable name.. Explained here: https://github.com/amanuel2/C-Examples/blob/master/Files/Reading/partone/main.cpp

  19. Im Lolly Avatar

    Just for the curious out here, deviding by zero will not blow up your computer!
    (code to test)
    int x = 10;
    while (true) {
    std::cout << 100 / x;

  20. nshusa Avatar

    Three dots is called variadic, functions can take multiple parameters by passing a variadic argument. Could mention #include <stdexcept>, throw exception vs catching an exception. Also maybe talk about the standard exception classes in C++ one could use to handle an exception.

  21. Fairwin Askara Avatar

    it's confusing. I tried with catch (int x) instead of catch (…) but it return the same result

  22. Batman Avatar

    but how will I use multiple exception I created this and it's not working!!

    #include <iostream>
    #include <string>
    using namespace std;

    int main()

    int mom=39;
    int son=18;
    int daughter=15;

    if (son && daughter >mom){

    throw 47;


    catch(int x){
    cout<<"son and daughter can't be older than mom you moron!! "<<endl;

    if (son > mom){

    throw 37;


    catch(int y)
    cout<<"son can't be older than mom you moron!!"<<endl;

    if (daughter > mom ) {

    throw 57;

    catch(int z) {

    cout<<"daughter can't be older than mom you moron!!"<<endl;


  23. letsroll Avatar

    heres how to pass an exception class into main:

    #include <iostream>
    #include <stdexcept> // must include this directory

    using namespace std;

    class whatexception : public exception
    // leave empty for now for simplicity

    int main()

    try {
    int i = 0;
    if (i == 0)
    throw whatexception();

    }catch (whatexception)
    cout << " lol u got me , i == 0 " << endl;

    return 0;


  24. Ekanshdeep Gupta Avatar

    1. Should all code be run inside the try block? Or is it better to input everything outside the try block, and only use the try block to check against various errors?

    2. What is the point of (…)? Isn't (int x) doing the same thing? catching all the errors, and placing their throw values in x?

    3. Can you independently use a catch function without a try function? Would that even make sense? Could you have multiple catch blocks for a try block, to implement variable overloading or something?

    4. And, lastly, how would you go about implementing a personalized message for each different error throw value? Is if-else-if inside the catch block the best way to go, or is there a better suited, more formalized way of doing it?

  25. J Reid Avatar

    could you done a vid on inheritance from exception classes?

  26. Nelson Levi Wong Avatar

    why can't we use IF ELSE instead ? isn't it the same ?

  27. Riseout Avatar

    It seems that you can not get more than one catch per try , don't you?

  28. Setorrs11 Avatar

    if i use the catch(…) thing how can i still show the "x" number from the throw thing

  29. Ciaran Watters Avatar

    cin was covered very quickly in 20 – Sentinel Controlled Program, Thanks Bucky for your great work on putting this play list together.

  30. Sons_of_Liberty Avatar

    Wished viewers would stop using the comments section to say "thanks Bucky!" Instead of asking questions. It makes its harder for people to go thru all this rambling to get to actual questions. If you want to thank the uploaded please use YouTube's message feature. It's what it's there for. You people are the reason why YouTube needs exception handling.

  31. sportacus509 Avatar

    Can you use templates with catch?

  32. Legacy Avatar

    gotta catch em all

  33. bigZig Zag Avatar

    Do these exceptions have anything to do with why people don't like using the C++ Standard Library? I always here people don't like using it because it uses exceptions but I never understood what that meant. Can someone please clarify?

  34. Bash Bdee Avatar

    Pretty Cool HA   xD damn Always

  35. Kostas Lek Avatar

    Does the catch(…) exist in Java as well?

  36. Mostarba Taj Avatar

    The math gods will not allow it LOL

  37. Matthew Sam Suren Avatar

    "dot dot dot" is commonly called the ellipsis.

  38. Frozen Vortex Avatar

    Its called Varag Expression in Lua

  39. Bob The Zealot Avatar

    can you catch a pointer or array?

  40. Attila Molnár Avatar

    It is good to know that you can use "(…)" in functions and the receive unnamed arguments. These arguments accessible with macros from the "stdarg.h" header. Nice tutorial. 

  41. Pejman Saberin Avatar

    great tutorial and explanation

  42. funtube99999 Avatar

    This "dot dot dot" thingy means it is a 'variadic function'. That's what we call it.
    Apart from that, good stuff man.

  43. Microtardz Avatar

    Or you could not suggest people use goto's unnecessary, and put your whole try catch into a while(1) loop, with a break statement for when everything goes alright.
    Which would be the structured way to handle this. Or, you could use a do while loop with a check for a flag to see if it went without a hitch, if it didn't, you'd just have it loop back.

  44. தமிழ்BassBoost Avatar

    only 24000 views :O stay strong buddy we can make it 🙂

  45. woob wuub Avatar

    2 years old top comment. Jeeeez.

Leave a Reply

Your email address will not be published. Required fields are marked *