Monday, May 24, 2010

Debug the program(timer.h in c++)?

neccessary the header files are included


void main()


{


Timer t;


t.start();


delay(200);


t.stop();


cout%26lt;%26lt;t.time();


getch();


}


the error is


linker error:undefined symbol Timer::start() in module noname00.cpp


linker error:undefined symbol Timer::stop() in module noname00.cpp


linker error:undefined symbol Timer::time() in module noname00.cpp





please debug it else tell me another code for stop watch in c++.

Debug the program(timer.h in c++)?
Any time you get some kind of "undefined symbol error," you should first check that you have included all the library files that your program needs.





The problem here is that you forgot to pass the library file which has the timer:: functions to the linker.





Look in your C++ compiler's help files to find out which .LIB file contains the Timer:: functions and include the .LIB file.
Reply:the timer class should be defined in your program or should be there in any package files as in #include packages ...


I am not very sure about the include file but you can check in the documentation of your compiler
Reply:You have used Timer t; Which is some kind of object that has the start, and stop methods. You included the proper include files or the compiler would have complained about a missing symbol. What is complaining is the the linker. The linker is the program that put the binary parts together. As in the compiler will take what you typed in an change it into binary, but you reference other things like Timer which come from other binary parts, as in a library.





You need to look at the documentation for Timer and it will tell you not only which include file(s) to include, but also the library you need (most likely a .lib). Then you need to change your project settings so that the linker adds that library to the link.
Reply:It seems that start(), stop() and time() are undefined in the Timer class. Where is Timer coming from? Presumably you've included it from somewhere - check your source and make sure you're using it correctly, and that your spelling (including case) is correct.





Rawlyn.
Reply:you can search in www.google.com....


No comments:

Post a Comment