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 -

#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();
}

Please some body help me in removing this error....

Tnak you every body in Advance...........

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.

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

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

A function defined inside a class is automatically request the compiler to make it inline:

class foo
{ 
    int f1()
    {
        //the definition
       // This function is inline
    }
    int f2();
}
int foo::f2()
{
  //the definition goes here
  //function is not 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.

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.

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.

I normally wont go into small errors in other peoples posting,
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?

Comments
Oops! My Bad.
This article has been dead for over six months. Start a new discussion instead.