473,386 Members | 1,764 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,386 software developers and data experts.

error LNK2019: unresolved external symbol "double __cdecl setTotalCost(void)"

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
1>c:\users\rafael jr\documents\visual studio 2010\Projects\Inventory CS226\Debug\Inventory CS226.exe : fatal error LNK1120: 1 unresolved externals

Can anyone please tell me where my error is or what i'm doing wrong?


here is my code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include "Inventory.h"
  4. #include <limits>
  5. /*using std::cin;
  6. using std::cout;
  7. using std::endl;    */
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     int itemNumber, quantity;
  13.     double cost;
  14.     bool failed;
  15.     Inventory uItem;
  16.     double setTotalCost(); //function prototype
  17.     do
  18.         {
  19.         // User entering Item Number
  20.         uItem.setItemNumber(1);
  21.         cout<< "Please enter the Item number: "<< endl;
  22.         cin>> itemNumber;
  23.         if(itemNumber < 0 || itemNumber > 100 )
  24.         {
  25.             cout << "Sorry we do not accept negative values for Item Number" << endl;
  26.             failed=true;
  27.         }
  28.         else
  29.         {
  30.             failed=false;
  31.             cout << "Item Number entered: "<< itemNumber<< endl;
  32.         }while (failed == true ||  itemNumber < 0 );  // If user enters 0, then exit out
  33.  
  34.  
  35.         // User entering Quantity Amount
  36.         uItem.setQuantity(1);
  37.         cout<< "Please enter the Quantity Amount: "<< endl;
  38.         cin>> quantity;
  39.         if(quantity < 0 || quantity > 100 )
  40.         {
  41.             cout << "Sorry we do not accept negative values for the Quantity Amount" << endl;
  42.             failed=true;
  43.         }
  44.         else
  45.         {
  46.             failed=false;
  47.             cout << "Quantity Amount entered: "<< quantity<< endl;
  48.         }while (failed == true ||  quantity < 0 );  // If user enters 0, then exit out
  49.  
  50.  
  51.         // User entering Cost
  52.         uItem.setCost(1);
  53.         cout<< "Please enter the Cost of the Item: "<< endl;
  54.         cin>> cost;
  55.         if(cost < 0 || cost > 100 )
  56.         {
  57.             cout << "Sorry we do not accept negative values for the Item Cost" << endl;
  58.             failed=true;
  59.         }
  60.         else
  61.         {
  62.             failed=false;
  63.             cout << "Item Cost entered: "<< cost<< endl;
  64.         }
  65.         }while (failed == true ||  cost < 0 );  // If user enters 0, then exit out
  66.  
  67.  
  68.         // Calculation of Total Cost
  69.         cout<< " What is the Total Cost? "<<endl;
  70.         cout<< " The Total Cost is: "<< "$" <<setTotalCost<<endl;
  71.  
  72.         system("pause");
  73.         return 0;
  74.     }
Feb 14 '11 #1
2 5813
horace1
1,510 Expert 1GB
the linker is unable to find the function prototyped in the statement
Expand|Select|Wrap|Line Numbers
  1. double setTotalCost(); //function prototype
  2.  
have you spelt the name correctly? is it in another .cpp file?
also when you call it
Expand|Select|Wrap|Line Numbers
  1. cout<< " The Total Cost is: "<< "$" <<setTotalCost<<endl;
  2.  
you have missed the ()
Feb 14 '11 #2
Oralloy
988 Expert 512MB
Actually, the use of setTotalCost in the output line will likely just print the hex value of the address of the function. That's a logic error, not a coding error.

The other thing to check is that you didn't spell the word differently in two places - setTotalCost and SetTotalCost are two different function names.

Lastly, make sure you aren't compiling setTotalCost as a "C" function or placing it in a different namespace from your main(...)

Good luck with your assignment.

Oralloy
Feb 14 '11 #3

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

Similar topics

3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
24
by: hjbortol | last post by:
Hi! Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++? Is this equivalence an IEEE/ANSI rule? Or is this machine/compiler dependent? Any references are welcome! Thanks in...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
7
by: sunglo | last post by:
My doubt comes from trying to understand how thread return values work (I know, it's off topic here), and I'm wondering about the meaning of the "void **" parameter that pthread_join expects (I...
2
by: | last post by:
My hear is dropping out of these linker errors of VC++ .NET. :-( I try to create a mixed managed/unmanaged .NET dll to be used for my futur projects, but I always bump in a linker error and no way...
1
by: Michael | last post by:
Hello dear .Net experts I have created a Visual C++ class library (.net) project with two classes named Base and Derived wher Derived inherits from Base. When I add a destructur to base I get the...
2
by: Pardeep Kadian | last post by:
Hi , having as issue , which gives errors like this while linking... error LNK2019: unresolved external symbol "public: __thiscall std::ios_base::Init::Init(void)"...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
2
by: Lionel B | last post by:
I frequently seem to run into the following annoyance regarding template class specialisation: I have a template class which implements, for a general template parameter, some basic functionality...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.