473,698 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
Hello All, I was writing a program and ran across this error:

error LNK2019: unresolved external symbol "double __cdecl setTotalCost(vo id)" (?setTotalCost@ @YANXZ) referenced in function _main
1>c:\users\rafa el jr\documents\vi sual studio 2010\Projects\I nventory CS226\Debug\Inv entory 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 5833
horace1
1,510 Recognized Expert Top Contributor
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 Recognized Expert Contributor
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
2473
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 wrong? I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains: //**************************** //**************************** Compiler output starts *********** cd /home/red/tmp/testprogs/
24
3608
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 advance, Humberto.
13
3101
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" automatically after programs do "delete p"?
7
2483
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 think this is topical, since it's a C question, but please correct me and apologies if I'm wrong). I suppose that it's this way to allow for "generic" pointer modification, but this implies dereferencing the "void **" pointer to get a "void *"...
2
7619
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 to get around this... The error is: sLibBase error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcmtd.lib(dbgdel.obj) These are 2 the same header files. The first uses <string> and generates the link...
1
3415
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 following linker error Common.obj : error LNK2001: Unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)(void *),void *)" (?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z This does not happen when there is no detructor in...
2
2248
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)" (??0Init@ios_base@std@@QAE@XZ) referenced in function "void __cdecl std::`dynamic initializer for '_Ios_init''(void)" (??__E_Ios_init@std@@YAXXZ)
1
7291
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: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol
13
27429
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
3812
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 (i.e. set of methods). But either: 1) For one (or a few) particular methods, the implementation will be specialised for many possible template parameters, or 2) For one particular template parameter, one (or a few) methods will have a...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.