没有收到通过的价值 [英] Passed value not being received

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

问题描述

我有一个简单的类方法,它接收第二个参数

unsigned int。但是,无论我做什么,它都不会收到我传递给它的

值。相反,它总是出现4198769.我已经将b $ b作为一个文字,一个变量和一个常数传递给了b
这个方法仍然可以获得更大,更不可行的数据价值。


我已经尝试改变我传递给它的价值而且我已经尝试过施展

常数而且它仍然出错了。我无法想象一个破坏者(VS

2005)被打破到足以打破这个。


对此有何看法? 4198769似乎与

无关。


-

谢谢,

Lilith

I have a simple class method that receives as its second parameter an
unsigned int. But, regardless of what I do it never receives the
value that I pass to it. Instead it always comes up 4198769. I''ve
passed the number as a literal, as a variable and as a constant and
the method still recives the larger, unviable value.

I''ve tried changing the value I pass to it and I''ve tried casting a
constant and it still comes out wrong. I can''t imagine a compler (VS
2005) being broken enough to do this.

Any thoughts on this? 4198769 doesn''t seem to be relevant to
anything.

--
Thanks,
Lilith

推荐答案

Lilith写道:
Lilith wrote:

我有一个简单的类方法接收作为其第二个参数的

unsigned int。但是,无论我做什么,它都不会收到我传递给它的

值。相反,它总是出现4198769.我已经将b $ b作为一个文字,一个变量和一个常数传递给了b
这个方法仍然可以获得更大,更不可行的数据价值。


我已经尝试改变我传递给它的价值而且我已经尝试过施展

常数而且它仍然出错了。我无法想象一个破坏者(VS

2005)被打破到足以打破这个。


对此有何看法? 4198769似乎与

无关。
I have a simple class method that receives as its second parameter an
unsigned int. But, regardless of what I do it never receives the
value that I pass to it. Instead it always comes up 4198769. I''ve
passed the number as a literal, as a variable and as a constant and
the method still recives the larger, unviable value.

I''ve tried changing the value I pass to it and I''ve tried casting a
constant and it still comes out wrong. I can''t imagine a compler (VS
2005) being broken enough to do this.

Any thoughts on this? 4198769 doesn''t seem to be relevant to
anything.



发布一个演示问题的最小例子。您可能会在构建示例的过程中修复问题。


-

Ian Collins。

Post a minimal example that demonstrates the problem. You will probably
fix the problem in the process of constructing the example :)

--
Ian Collins.


On Thu,2007年12月20日11:27:44 +1300,Ian Collins< ia ****** @ hotmail.com>

写道:
On Thu, 20 Dec 2007 11:27:44 +1300, Ian Collins <ia******@hotmail.com>
wrote:

> Lilith写道:
>Lilith wrote:

>我有一个简单的类方法接收作为它的第二个参数
unsigned int。但是,无论我做什么,它都永远不会收到我传递给它的价值。相反,它总是出现4198769.我已经将数字作为文字,变量和常量传递,
该方法仍然可以获得更大,更不可行的价值。
常量,但它仍然出错了。我无法想象一个破坏者(VS
2005)被打破到足以做到这一点。

对此有什么看法? 4198769似乎与
任何东西无关。
>I have a simple class method that receives as its second parameter an
unsigned int. But, regardless of what I do it never receives the
value that I pass to it. Instead it always comes up 4198769. I''ve
passed the number as a literal, as a variable and as a constant and
the method still recives the larger, unviable value.

I''ve tried changing the value I pass to it and I''ve tried casting a
constant and it still comes out wrong. I can''t imagine a compler (VS
2005) being broken enough to do this.

Any thoughts on this? 4198769 doesn''t seem to be relevant to
anything.


发布一个演示问题的最小例子。您可能会在构造示例的过程中解决问题:)

Post a minimal example that demonstrates the problem. You will probably
fix the problem in the process of constructing the example :)



类中的原型:

void DrawBlock (点p,unsigned int size,sf :: Color c);


方法:

void Roads :: DrawBlock(点p,unsigned int size, sf ::颜色c)

//尺寸总是显示为4198769

{

int left = px - size / 2;

int,top = py - size / 2;


for(int i = top; i< top + size; i ++){

for(int j = left; j< left + size; j ++){

canvas-> SetPixel(j,i,c);

}

}


}


调用方法:

.. < br $> b $ b ..

const unsigned int siz = 5;

..

..

fin.x = 80;

fin.y = 20;

..

..


Roadway.DrawBlock(fin,siz,Red);


它的大小始终以相同的价值出现这是我在通话中传递的内容。


-

Lilith

Prototype within the class:
void DrawBlock (point p, unsigned int size, sf::Color c);

Method:
void Roads::DrawBlock (point p, unsigned int size, sf::Color c)
// size always shows up as 4198769
{
int left = p.x - size/2;
int, top = p.y - size/2;

for (int i = top; i < top + size; i++) {
for (int j = left; j < left + size; j++) {
canvas->SetPixel(j, i, c);
}
}

}

Call to the method:
..
..
const unsigned int siz = 5;
..
..
fin.x = 80;
fin.y = 20;
..
..

Roadway.DrawBlock (fin, siz, Red);

It''s the size that keeps showing up with the same value regardless of
what I pass it in the call.

--
Lilith


12月19日晚上11点42分,Lilith< lil ... @ dcccd.eduwrote:
On Dec 19, 11:42 pm, Lilith <lil...@dcccd.eduwrote:

2007年12月20日星期四11 :27:44 + 1300,Ian Collins< ian-n ... @ hotmail.com>

写道:
On Thu, 20 Dec 2007 11:27:44 +1300, Ian Collins <ian-n...@hotmail.com>
wrote:

Lilith写道:
Lilith wrote:

我有一个简单的类方法,它接收第二个参数

unsigned int。但是,无论我做什么,它都不会收到我传递给它的

值。相反,它总是出现4198769.我已经将b $ b作为一个文字,一个变量和一个常数传递给了b
这个方法仍然可以获得更大,更不可行的数据值。
I have a simple class method that receives as its second parameter an
unsigned int. But, regardless of what I do it never receives the
value that I pass to it. Instead it always comes up 4198769. I''ve
passed the number as a literal, as a variable and as a constant and
the method still recives the larger, unviable value.


我试过改变传递给它的值我试过了施了一个

常数,但它仍然出错了。我无法想象一个破坏者(VS

2005)被打破到足以做到这一点。
I''ve tried changing the value I pass to it and I''ve tried casting a
constant and it still comes out wrong. I can''t imagine a compler (VS
2005) being broken enough to do this.


对此有何想法? 4198769似乎与

无关。
Any thoughts on this? 4198769 doesn''t seem to be relevant to
anything.


发布一个演示问题的最小示例。您可能会在构建示例的过程中解决问题
修复问题:
Post a minimal example that demonstrates the problem. You will probably
fix the problem in the process of constructing the example :)



班级中的原型:

void DrawBlock(点p,unsigned int size,sf :: Color c);


方法:

void Roads :: DrawBlock(点p, unsigned int size,sf :: Color c)

// size总是显示为4198769

{

int left = px - size / 2;

int,top = py - size / 2;


for(int i = top; i< top + size; i ++){

for(int j = left; j< left + size; j ++){

canvas-> SetPixel(j,i,c);

}

}


}


调用方法:





const unsigned int siz = 5;





fin.x = 80;

fin.y = 20;






道way.DrawBlock(fin,siz,Red);


Prototype within the class:
void DrawBlock (point p, unsigned int size, sf::Color c);

Method:
void Roads::DrawBlock (point p, unsigned int size, sf::Color c)
// size always shows up as 4198769
{
int left = p.x - size/2;
int, top = p.y - size/2;

for (int i = top; i < top + size; i++) {
for (int j = left; j < left + size; j++) {
canvas->SetPixel(j, i, c);
}
}

}

Call to the method:
.
.
const unsigned int siz = 5;
.
.
fin.x = 80;
fin.y = 20;
.
.

Roadway.DrawBlock (fin, siz, Red);



我没有看到明显的问题。你是通过价值传递的。

没有隐含的转换(不是说它会b / b)。也许尝试这个最小的例子:


#include< iostream>


void DrawBlock(无符号大小)

{

std :: cout<< "大小" << std :: endl;

}


int main()

{

const unsigned sz (5);

DrawBlock(sz);

}


然后看看打印的是什么。如果值仍然如上所述,

我建议您更改参数的名称size。一些东西

其他,因为它可能是宏扩展(唯一的另一件事是我能想到的
)。


问候,


Werner

I don''t see an obvious problem. You are passing by value.
There are no implicit conversions (not that it would
matter). Perhaps try this minimal example:

#include <iostream>

void DrawBlock( unsigned size )
{
std::cout << "size" << std::endl;
}

int main()
{
const unsigned sz( 5 );
DrawBlock( sz );
}

Then see what is printed. If the value is still as mentioned,
I suggest you change the name of the argument "size" to something
else, as it may be that it is macro expanded (the only other thing
I can think of).

Regards,

Werner


这篇关于没有收到通过的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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