Thread: try keyword does't work

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    4

    try keyword does't work

    I tried to write a c++ program using exception handling (try/catch).While compiling,it shows the error message"undefined symbol try".How can overcome it?Please give me a solution.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Are you sure you are compiling as C++? What is this program that you tried?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You're not trying to do this with some 20+ year old "Turbo" thing are you?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    4
    yes,I'm using it as a cpp file....but..shows the same

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    4
    ya its a cpp file...even if its a simple program (like division by zero) it shows the same error

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Try compiling this program:
    Code:
    #include <vector>
    #include <new>
    
    int main()
    {
        try
        {
            std::vector<int> numbers(1000);
            numbers.resize(2000);
        }
        catch (const std::bad_alloc& e)
        {
        }
    }
    If there is an error, show the entire error message.

    What compiler are you using?
    Last edited by laserlight; 07-13-2010 at 11:16 AM. Reason: <new> is the header for std::bad_alloc.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Jul 2010
    Posts
    4
    turbo c++ version.3
    the pgm shows 5 errors

    unable to open include file'VECTOR'
    unable to open include file'NEW'
    undefined symbol try
    statement missing ;
    compund stmt missing }
    function should return a value
    Last edited by arunvl; 07-13-2010 at 11:36 AM.

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Time to change compiler. There is no other way, unless you want to learn pre-standard C++ and be obsolete even before you have started.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    perhaps slightly off topic, but where the hell do people keep coming up with turbo C 3.0? are colleges still using that crap and providing it to their students? if so, do they not realize that they are setting their students up for failure? it's ridiculous that a college would offer a class on C++ and not even teach a standard version of it. there are free standards-compliant C++ compilers available, and anyone who would deliberately use a non-standard compiler is only shooting him/herself in the foot.

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Apparently, TurboCrap is the MANDATED compiler for the entire Indian sub-continent.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Southern Asia in general, it seems. Pakistan, Phillipines, Sri Lanka, Nepal, and Bangladesh are among the other countries that seem to favor these old things.

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    It just seems odd because this is at least the second thread related to TC3 within the last few days, and it seems to come up at least a few times a month as well. is it available to download for free somewhere?

  13. #13
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I don't think it is anymore, but for a very long time you could download compiler releases of the "TurboC", "TurboC++", "Borland C++", series and several other Borland and Inprise development tools from their support website.

    You can probably still find them linked through archival services.

    [Edit]
    That isn't to say that people are legally allowed to distribute those tools. The developers didn't require you to register or anything, but they were technically provided as part of legacy support for current generation tool suites.
    [/Edit]

    Soma
    Last edited by phantomotap; 07-13-2010 at 03:46 PM. Reason: none of your business

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  2. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  3. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM