内置数据类型的默认初始化 [英] default initialization for built in data types

查看:59
本文介绍了内置数据类型的默认初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我研究了每种内置数据类型都支持一种特殊的构造函数语法,以将其对象初始化为零.

Hi,

I have studied that each built-in data type supports a special constructor syntax to initialize its object to zero.

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

Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5
Installed Edition: Professional
Microsoft Visual C++ 2008


编译器,我得到一个链接器错误,其中指出以下内容:
错误1错误LNK2019:函数_main
中引用的未解析的外部符号"int__cdecl MyNumber(void)"(?abc @@ YANXZ)
请帮帮我,
在此先感谢.


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.

推荐答案

此错误表示您使用的函数在任何地方都未定义.看看是否缺少MyNumber()的函数定义.
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().



我找到了解决方案,将代码从
Hi,
I got the solution,changed the code from
int MyNumber();cout << MyNumber;

更改为

int MyNumber=int();cout << MyNumber;


现在我可以将MyNumber初始化为0.谢谢你们的答复.


Now I am able to get the MyNumber initialized to 0.Thank you both for your replies.


这篇关于内置数据类型的默认初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆