| | |
LinKer Error for Static Function
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
Hi Every Body
I am new born in C++ I am facing and error for last 3 days I tried my best with all what I knew but FAILED.....
Error is -
" Linker Error: Undefined Symbol Library::code in module PRGDONE.CPP"
I am using Turbo C++ 3.0 of Borland
Here is the code -
Please some body help me in removing this error....
Tnak you every body in Advance...........
I am new born in C++ I am facing and error for last 3 days I tried my best with all what I knew but FAILED.....
Error is -
" Linker Error: Undefined Symbol Library::code in module PRGDONE.CPP"
I am using Turbo C++ 3.0 of Borland
Here is the code -
c Syntax (Toggle Plain Text)
#include<iostream.h> #include<conio.h> #include<iomanip.h> #include<process.h> #include<stdio.h> #include<stdlib.h> class library { int sum,total,choice ,no; static int code,a,c,p,m,d,e,h,f,z; public: void text() { while(no<121||no>125) { cout<<"\n enter the card no.between(121 to 125):"; cin>>no; if(no<121||no>125) { cout<<"\n incorrect no."; cout<<"\n enter the card no. again:"; } else { break; } } } void text1() { cout<<"\n\n"<<setw(39)<<" ------------ "; cout<<"\n\n"<<setw(39)<<" | LIBRARY | "; cout<<"\n\n"<<setw(39)<<" ------------ "; cout<<"\n\n\n"<<"1 BOOKS"; cout<<"\n"<<"2 GET"; cout<<"\n"<<"3 EXIST"; cout<<"\n\n ENTER YOUR CHOICE::"; cin>>choice; switch (choice) { case 1: cout<<"\n BOOKS DETAIL"; cout<<"\n BOOK NAME CODE QUANTITY"; cout<<"\n chemistry 1001 5"; cout<<"\n panipath war 1002 5"; cout<<"\n maths 1003 5"; cout<<"\n develop personality 1004 5"; cout<<"\n Computer advance 1005 5"; cout<<"\n how to learn 1006 5"; cout<<"\n Phycs today 1007 5"; break; case 2: cout<<"\n BOOK AVAILABLE\n"; total=35; cout<<" TOTAL BOOK THAT CAN BE ISSUED:"; cout<<total<<endl; break; case 3: break; default: cout<<"\n YOU HAVE ENTERED WRONG VALUE"; } } static void work() { while(code<1001 ||code>1007) { cout<<"\n ENTER THE CODE BETWEEN (1001 TO 1007)"; cin>>code; if (code<1001 || code>1007) { cout<<"INVALID CODE(book not available)"; } else { switch(code) { case 1001: for(c=1;c<=5;c++) { cout<<"\nbook available of code 1001:"<<c; } break; case 1002: for(p=1;p<=5;p++) { cout<<"\n book available of code 1002:"<<p; } break; case 1003: for(m=1;m<=5;m++) { cout<<"\n book available of code 1003:"<<m; } break; case 1004: for(d=1;d<=5;d++) { cout<<"\n book available of code 1004:"<<d; } break; case 1005: for(e=1;e<=5;e++) { cout<<"\n book available of code 1005:"<<e; } break; case 1006: for(h=1;h<=5;h++) { cout<<"\n book available of code 1006 :"<<h; } break; case 1007: for(f=1;f<=5;f++) { cout<<"\n book available of code 1007:"<<f; } break; } for(z=1;z<=5;z++) { cout<<"\n card holder issued book"<<z; } for(a=1;a>=35;a--) { cout<<"\ntotal no.of books available"<<a; } } } } }; int library::a=0; int library::c=0; int library::p=0; int library::m=0; int library::d=0; int library::h=0; int library::f=0; int library::z=0; int library::e=0; void main() { clrscr(); library l1; l1.text(); l1.text1(); library::work(); getch(); }
Tnak you every body in Advance...........
Last edited by Ancient Dragon; Jun 17th, 2009 at 9:05 am. Reason: add code tags
Welcome to Daniweb and Also to C++, Firstly Please Use CODE TAGS the next time you post in your question,
Firstly I see that you are Using a outdated compiler. Though it is not il-legal to use it . It is considered better if you use a modern compiler like CODE::BLOCKs etc.
Next Would you also specify at which line do you get that error, so it will be much easier to figure it out.
Firstly I see that you are Using a outdated compiler. Though it is not il-legal to use it . It is considered better if you use a modern compiler like CODE::BLOCKs etc.
Next Would you also specify at which line do you get that error, so it will be much easier to figure it out.
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
Thank you for your reply its exactly not compilation error. Error is coming while running the program after compilation
" Linker Error: Undefined Symbol Library::code in module PRGDONE.CPP"
Line Number is not mentioned in error, but when I comment the line - library::work(); in main function then I get Success message
Please help me out.
Thank you
" Linker Error: Undefined Symbol Library::code in module PRGDONE.CPP"
Line Number is not mentioned in error, but when I comment the line - library::work(); in main function then I get Success message
Please help me out.
Thank you
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
Dear Dragon
Thank you very very much for helping mebut now I am 3 compilation warings are coming on line no 14, 40, 63 errors are -
Functions containing while are not expanded inline
Functions containing switch are not expanded inline
Functions containing while are not expanded inline
respectively .
I will be thankfull to you for your kind cooperation
Regards
Vishal
Thank you very very much for helping mebut now I am 3 compilation warings are coming on line no 14, 40, 63 errors are -
Functions containing while are not expanded inline
Functions containing switch are not expanded inline
Functions containing while are not expanded inline
respectively .
I will be thankfull to you for your kind cooperation
Regards
Vishal
A function defined inside a class is automatically request the compiler to make it inline:
In above example f1 is inline while f2 is not.
In general, a inline function cannot contain loops or switch statements. Hence your compiler is making that warning.
Note that the style of your coding is 15 year old and is deprecated( I call such code as "rusted"). Sky Diploma is right in giving you advice to use a modern compiler ( I bet you would be using something as crappy as Turbo C++).
Please read this and migrate to standard.
cpp Syntax (Toggle Plain Text)
class foo { int f1() { //the definition // This function is inline } int f2(); } int foo::f2() { //the definition goes here //function is not inline }
In general, a inline function cannot contain loops or switch statements. Hence your compiler is making that warning.
Note that the style of your coding is 15 year old and is deprecated( I call such code as "rusted"). Sky Diploma is right in giving you advice to use a modern compiler ( I bet you would be using something as crappy as Turbo C++).
Please read this and migrate to standard.
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Inlining is optional for compilers -- they may choose to honor it or not. Most compilers will honor one or two line inline functions, but the ones you posted are probably just too large to make inlining practical. IMO its better to put the implementation code for large functions in the *.cpp file instead of attempting to inline them.
•
•
Join Date: Aug 2008
Posts: 149
Reputation:
Solved Threads: 8
•
•
•
•
Firstly I see that you are Using a outdated compiler. Though it is not il-legal to use it . It is considered better if you use a modern compiler like CODE::BLOCKs etc.
but it should be noted that code::blocks is an ide.
The compiler is most likely(depending on the setup) the mingw compiler. The mingw is a subset of the gnu toolchain.

I dont like being a correction nazi,
but the difference between compiler and ide/editor is quite important.
cheers!
To the original poster.
Is it nescesarry to use static variables for you program?
Last edited by monkey_king; Jun 17th, 2009 at 11:05 pm.
![]() |
Similar Threads
- Linker error help? (C++)
- combine functions and linker error?? (C++)
- Linker Error (Undefined Reference) (C++)
- Linker Error (C++)
- Modifying Form's Clientsize in a static function (C)
- Linker Error>Undefined reference error to xyz (C++)
- HELP: class static function - compile errors (C++)
- static function? help (C++)
Other Threads in the C++ Forum
- Previous Thread: Which is faster/more efficient c++´s fstream, or c's FILE
- Next Thread: Read function from text file
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






