愚蠢的问题 [英] silly question

查看:73
本文介绍了愚蠢的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class foo

{

foo();

private:

char table [64];

}


foo :: foo()

{

table [0] =' 'a'';

}


为什么以上不起作用?

class foo
{
foo();
private:
char table[64];
}

foo::foo()
{
table[0] = ''a'';
}

Why doesnt the above work ?

推荐答案

earl写道:

class foo
{
foo();
私人:
char table [64];
}

foo :: foo()
{
表[0] ='''';
}
为什么不进行上述工作?

class foo
{
foo();
private:
char table[64];
}

foo::foo()
{
table[0] = ''a'';
}

Why doesnt the above work ?




缺少分号。


-


Pete Becker

Dinkumware,Ltd。( http:// www .dinkumware.com




" earl" < b@email.com>在留言新闻中写道:3f ****** @ news.broadpark.no ...

"earl" <b@email.com> wrote in message news:3f******@news.broadpark.no...
class foo
{
foo();
私人:
char table [64];
}

foo :: foo()
{
table [0] =''a'';
}

为什么上面的工作没有?
class foo
{
foo();
private:
char table[64];
}

foo::foo()
{
table[0] = ''a'';
}

Why doesnt the above work ?




除了你在课程结束时留下分号之外的事实

定义。



Well other than the fact you left a semicolon off the end of the class
definition.


earl写道:
earl wrote:
class foo
{
foo();
私人:
char table [64];
}
foo :: foo()
{
表[ 0] ='''';
}

为什么上述工作不起作用?
class foo
{
foo();
private:
char table[64];
}

foo::foo()
{
table[0] = ''a'';
}

Why doesnt the above work ?




您无法实例化变量一个类定义。也就是说,你没有
无法为数组分配内存或初始化变量。一种方法

你要做的就是使用char * table在定义中,然后malloc

表的空间。


-charles



You cannot instantiate a variable in a class definition. That is, you
cannot allocate memory to an array or initialize a variable. One way to do
what you wan to do is use "char* table" in the definition, and then malloc
space for the table.

-charles


这篇关于愚蠢的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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