Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I have studied that each built-in data type supports a special constructor syntax to initialize its object to zero.
XML
For example:
// sets ival to 0, dval to 0.0
int ival = int();
double dval = double();
In the following definition,
// int() applied to each of the 10 elements
vector< int > ivec( 10 );


But when I tried this on my
MSIL
Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5
Installed Edition: Professional
Microsoft Visual C++ 2008

compiler,I am getting a linker error which states the following:
Error 1 error LNK2019: unresolved external symbol "int__cdecl MyNumber(void)" (?abc@@YANXZ) referenced in function _main

Please help me out,
Thanks in advance.
Posted

This error means that you have a function that you used that is not defined anywhere. See if you're missing the function definition for MyNumber().
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-May-11 23:00pm    
My 5. Now OP will probably ask you where to get this function :-)
--SA
Hi,
I got the solution,changed the code from
int MyNumber();cout << MyNumber;
to
int MyNumber=int();cout << MyNumber;

Now I am able to get the MyNumber initialized to 0.Thank you both for your replies.
 
Share this answer
 
v2
Comments
Legor 23-May-11 7:50am    
Well thats not at all the code you've provided in your question.
If you would have, it would have been pretty clear what went wrong from the beginning.
hakz.code 23-May-11 8:06am    
Yes,I would keep that in mind!
Albert Holguin 24-May-11 9:33am    
int MyNumber() doesn't make sense, the error you received was because the compiler/linker assumed that MyNumber() was a function (as did I).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900