473,388 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

exception handing: error message "undefined symbol try . . "

how to work with expection handing in which when i am using try block then the error message coming that "undefined symbol try" why it is so, please solve my problem.
Jan 7 '09 #1
10 29371
gpraghuram
1,275 Expert 1GB
Can you post the piece of code where u are getting the error?
Also which compiler u are using?

Raghu
Jan 7 '09 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2. //Compile is turbo c++
  3.  
  4.  
  5. #include<iostream.h>
  6. #include<stdio.h>
  7. #include<conio.h>
  8. void main()
  9. {
  10. clrscr();
  11. int a,b;
  12. cout<<"Enter value of a and b\n";
  13. cin>>a>>b;
  14. int x=a-b;
  15. try
  16. {
  17. if(x!=0)
  18. {
  19. cout<<"Result(a/x)="<<a/x<<endl;
  20. }
  21. else
  22. {
  23. throw(x);
  24. }
  25. }
  26. catch(int i)
  27. {
  28. cout<<"Exption caughg:x="<<x<<endl;
  29. }
  30. cout<<"End";
  31. getch();
  32. }
  33.  
Jan 7 '09 #3
r035198x
13,262 8TB
Are you compiling as c or c++?
Is that the only error message you are getting?
Jan 7 '09 #4
then what I should do and how can i run my programme
Jan 7 '09 #5
Banfa
9,065 Expert Mod 8TB
You should start by re-writing void main() as int main(). Main returns an int, always, anything else is undefined behaviour.
Jan 7 '09 #6
r035198x
13,262 8TB
@arvindkuk
I don't think you started learning C++ by learning exceptions. How did you compile your hello world c++ program?
Jan 7 '09 #7
my problem is "undefined symbol try" how can I handle this
Jan 7 '09 #8
r035198x
13,262 8TB
Your problem is not being sure which language you are coding in. You want to use try/catch exception handling so you must use c++ not c.
For c++ you need to change these things

1.) replace #include<iostream.h> with #include<iostream>
2.) Remove all other includes
3.) add using namespace std; before the definition of main
4.) Make main return an int not void. void is wrong even in c
5.) Remove lines with clrscr(); and getch(); in your code
6.) Compile the file as a c++ file not as a c source file.
Jan 7 '09 #9
Banfa
9,065 Expert Mod 8TB
Something obvious that has not been mentioned yet is what is the name of your file?

if it is <something>.c then the compiler will almost certainly be compiling it as C code it needs to be <something>.cpp
Jan 7 '09 #10
weaknessforcats
9,208 Expert Mod 8TB
Also, keep in mind that exception handling is often turned off in most C++ compilers by default. You have have to enable it by setting a compiler switch.

That would explain your indefined symbol.
Jan 7 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: naveenadevi | last post by:
Hi, I'm trying to use some power management features with windowsx xp and I have visual studio .net 2003 installed. As per documentation of ACPI, you can use the power options by including...
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
0
by: Simon | last post by:
Hi All, I have come across a problem with a bog std MFC app linking to bog std MFC extension dll - both generated by the wizards. The code is set out below. The trouble is with the static...
0
by: =?Utf-8?B?TWF0ZXVzeiBSYWpjYQ==?= | last post by:
Hi! How can I fix this error? Error 1 error LNK2001: unresolved external symbol "extern "C" long __stdcall SHFlushClipboard(void)" (?SHFlushClipboard@@$$J10YGJXZ) UnmanagedTest.obj Basically...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
8
by: Soneji | last post by:
Hello all! ( again ) Once more, I have a problem that seems unsolvable by me. I'm getting the, seemingly common, "undefined reference" linking error. I've tried quite a few things, but...
1
by: grbgooglefan | last post by:
I am importing cStringIO module in my PythonC++ embedded program. The import is failing with the following error: ImportError: /usr/lib/python2.3/lib-dynload/cStringIO.so: undefined symbol:...
0
by: Nick S | last post by:
Hi I've found very little about this problem and was wondering if someone could help me. I've installed the Apache 2.0.63 and PHP 5.2.6 from the source code on my SuSe Linux 9.3 box. ...
2
by: Rafael Douglas | last post by:
Hello All, I was writing a program and ran across this error: error LNK2019: unresolved external symbol "double __cdecl setTotalCost(void)" (?setTotalCost@@YANXZ) referenced in function _main...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.