通用堆栈问题 [英] Generic Stack problem

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

问题描述



我有一个通用堆栈实现的代码。


----------------

void Push(void * value,void * Stack,int * top)

{

if(!(IsFull(Stack,top) ))

{

(* top)++;

Stack [* top] = * value;

}

}

-------------


我收到以下错误:


错误C2036:''void *'':未知大小


如何克服这个问题?有什么想法吗?


TIA,

诈骗。

解决方案

< blockquote>

Scamjunk写道:

我有一个通用堆栈实现的代码。

---------- ------
void Push(void * value,void * Stack,int * top)
{
if(!(IsFull(Stack,top)))
{
(* top)++;
Stack [* top] = * value;


你不能取消引用`void *`。

}
}
------ -------

我收到以下错误:

错误C2036:''void *'':未知大小

我该如何克服这个问题?有什么想法吗?




[snips]


On Thu,2006年4月27日03:35 :59-0700,Scamjunk写道:

void Push(void * value,void * Stack,int * top)
{
if(!(IsFull( Stack,top)))
{
(* top)++;
Stack [* top] = * value;
}
}
- ------------

我收到以下错误:

错误C2036:''void *'':未知大小



嗯......什么是无效*?这是一个指向虚空的指针。什么是虚空?

非类型。它没有大小,没有格式,它是一个黑洞,你无法读取



你的代码是做什么的?它将void *参数作为值。然后

确实:


堆栈[*顶部] = *值;


嗯。 = *值。分配由值指向的内存中的任何内容......

但是...... value是一个void指针;它指向一个空白,一个没有大小的项目,

没有实际类型,没有代表。


你怎么期望编译器找出正确的要做的事情来自

代码,它告诉它要检索,字面上,什么都没有?


你将不得不演员或处理打字更好一点或一点点

不同等等。


Scamjunk写道:


我有以下代码用于通用堆栈实现。

----------------
void Push(void * value,void * Stack,int *顶部)
{
if(!(IsFull(Stack,top)))
{
(* top)++;
Stack [* top] = *价值;
}
}
-------------

我收到以下错误:
错误C2036 :''void *'':未知大小
我如何克服这个?任何想法?




不要试图在void *


的对象中存储空格 -

"如果您想通过groups.google.com发布后续内容,请不要使用

损坏的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson

更多详细信息:< http://cfaj.freeshell.org/google/>

另见< http://www.safalra .com / special / googlegroupsreply />



I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:

error C2036: ''void *'' : unknown size

How do i overcome this? Any ideas?

TIA,
Scam.

解决方案


Scamjunk wrote:

I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
You''re not allowed to dereference a `void *`.
}
}
-------------

and am getting the following error:

error C2036: ''void *'' : unknown size

How do i overcome this? Any ideas?




[snips]

On Thu, 27 Apr 2006 03:35:59 -0700, Scamjunk wrote:

void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:

error C2036: ''void *'' : unknown size



Well... what is a void *? It''s a pointer-to-void. What''s a void? It is
a non-type. It has no size, no format, it is a black hole from which you
cannot read.

So what''s your code do? It takes a void * parameter as value. It then
does:

Stack[*top] = *value;

Hmm. = *value. Assign whatever''s in the memory pointed to by value...
but... value is a void pointer; it points to a void, an item with no size,
no actual type, no representation.

How do you expect the compiler to figure out the correct thing to do from
the code, which tells it to retrieve, literally, nothing?

You''re going to have to cast, or handle typing a little better or a little
differently, etc.


Scamjunk wrote:


I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:
error C2036: ''void *'' : unknown size
How do i overcome this? Any ideas?



By not trying to store a void in an object of type void*

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


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

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