after i try the 1st 1 from this web...
Cprogramming.com FAQ > Throwing exceptions (C++)
it says end1 is nnot a member of 'std'
how to solve this problem
oso i still dun understand how to use this for my project D:
pls help me
after i try the 1st 1 from this web...
Cprogramming.com FAQ > Throwing exceptions (C++)
it says end1 is nnot a member of 'std'
how to solve this problem
oso i still dun understand how to use this for my project D:
pls help me
You should be using endl, not end1 (as in lowercase L, not one).
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
thx for helping -just joined....
is there a simple and easy example to use3 try catch throw....
ZZZZ
Code:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <iostream> int func(void); void func2(void); int func(void) { int total1,seconds,minutes; do{ try { system ("cls"); printf("\nTask 4: Time count\n"); printf("==================\n"); printf("Please enter how many minutes to count down <5 minutes or less>:"); scanf("%d",&minutes); if(minutes>=0&&minutes<6) { printf("\n%02d:00\n",minutes); _sleep(100); minutes--; for(;minutes>=0;minutes--) { for(seconds=59;seconds>=0;seconds--) { printf("%02d:%02d\n",minutes,seconds); _sleep(100); } } _sleep(100); } else { system ("cls"); throw "out of range"; } } catch (const char *e) { std ::cerr <<e<<std::endl;; } _sleep(100); }while(minutes>=6||-1>minutes); } int main() { func(); return (0); }
It is silly to throw and catch an exception here. You should just perform that range check and act accordingly.
Furthermore, you should make your indentation more consistent. Unless you have special reasons to do otherwise, you should also use C++ style I/O rather than C style I/O. If you really did need to throw an exception, #include <stdexcept> and thow std::out_of_range rather than a string literal.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)