本文介绍了如何使用vc ++初始化float数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已初始化如下:
fvariable [100] = {0.0,0.0}在构造函数中,但是出现语法错误.
I have initialized as following:
fvariable[100] = {0.0, 0.0} in constructor but I got syntax error.
Is it not the right way to initialize it?
推荐答案
class MyClass
{
float fvariable[100];
public:
MyClass()
{
for (int n=0; n < sizeof(fvariable)/sizeof(fvariable[0]); n++)
{
fvariable[n] = 0.0;
}
}
};
:)
//declaration time
float fvariable[100] = { 0.0f };
//you can''t do that.
//fvariable[100] = { 0.0f };
//Or you can do as CPallini suggests:
for (int i = 0; i < 100; n++)
fvariable[i] = 0.0f;
但是它们是其他方式...
But they are other ways...
这篇关于如何使用vc ++初始化float数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!