二维数组模板 [英] Two Dimensional Array Template

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

问题描述

http://groups.google.com /group/comp....092f0f6c9bf13a


我认为operator []()成员函数无法正常工作,是吗?
其他人都知道如何制作模板来制作二维数组来自

std :: vectors ???我想使用普通的数组[ROW] [COL]语法。

http://groups.google.com/group/comp....092f0f6c9bf13a

I think that the operator[]() member function does not work correctly, does
anyone else know how to make a template for making two dimensional arrays from
std::vectors ??? I want to use normal Array[ROW][COL] Syntax.

推荐答案

在2007-01-02 00:03,Peter Olcott写道:
On 2007-01-02 00:03, Peter Olcott wrote:
http ://groups.google.com/group/comp....092f0f6c9bf13a

我认为operator []()成员函数无法正常工作,

其他人都知道如何制作一个用于制作二维数组的模板来自

std :: vectors ???我想使用普通的数组[ROW] [COL]语法。
http://groups.google.com/group/comp....092f0f6c9bf13a

I think that the operator[]() member function does not work correctly, does
anyone else know how to make a template for making two dimensional arrays from
std::vectors ??? I want to use normal Array[ROW][COL] Syntax.



在发布的代码中(您可以包括):


w_elem_type * operator [](t_Size i_index)

{

return& (m_data [i_index * m_rows]);

}


''i_index * m_rows'' - 对我来说似乎有点可疑。现在已经很晚了

我不会花太多时间考虑它,但我认为

''i_index / m_rows''会更正确,但我可能错了。在纸上画一个

3x3矩阵并进行数学计算。


-

Erik Wikstr?m

In the code posted (which you could have included):

w_elem_type * operator[]( t_Size i_index )
{
return & ( m_data[ i_index * m_rows ] );
}

The ''i_index * m_rows''-part seems kind of fishy to me. It''s quite late
right now and I wont spend time thinking much about it, but I think that
''i_index / m_rows'' would be more correct, but I might be wrong. Draw a
3x3 matrix on paper and do the math.

--
Erik Wikstr?m




" Erik Wikstr?m" < Er *********** @ telia.comwrote in message

新闻:hF ******************* @ newsb.telia.net ...

"Erik Wikstr?m" <Er***********@telia.comwrote in message
news:hF*******************@newsb.telia.net...

2007-01-02 00:03,Peter Olcott写道:
On 2007-01-02 00:03, Peter Olcott wrote:

> http://groups.google.com/group/ comp .... 092f0f6c9bf13a

我认为operator []()成员函数不能正常工作,是否有其他人知道如何制作模板以制作两个维数阵列
来自std :: vectors ???我想使用普通的数组[ROW] [COL]语法。
> http://groups.google.com/group/comp....092f0f6c9bf13a

I think that the operator[]() member function does not work correctly, does
anyone else know how to make a template for making two dimensional arrays
from std::vectors ??? I want to use normal Array[ROW][COL] Syntax.



在发布的代码中(您可以包括):


w_elem_type * operator [](t_Size i_index)

{

return& (m_data [i_index * m_rows]);

}


''i_index * m_rows'' - 对我来说似乎有点可疑。现在已经很晚了

我不会花太多时间考虑它,但我认为''i_index /

m_rows''会更正确,但我可能错了。在

纸上画一个3x3矩阵并做数学运算。


-

Erik Wikstr?m


In the code posted (which you could have included):

w_elem_type * operator[]( t_Size i_index )
{
return & ( m_data[ i_index * m_rows ] );
}

The ''i_index * m_rows''-part seems kind of fishy to me. It''s quite late right
now and I wont spend time thinking much about it, but I think that ''i_index /
m_rows'' would be more correct, but I might be wrong. Draw a 3x3 matrix on
paper and do the math.

--
Erik Wikstr?m



我已将所有内容部分转换为Array [ROW] [COL]顺序。我发现

我需要将上述功能转换为


return& (m_data [i_index * m_columns]);


我在发布此

消息后一分钟内发现了我的问题的解决方案。我链接的代码可能仍然正确。


感谢您的帮助。

I had partially converted everything over to Array[ROW][COL] order. I discovered
that I needed to convert the above function to

return & ( m_data[ i_index * m_columns ] );

I discovered this solution to my problem within a minute after I posted this
message. The code that I had linked to may still be correct.

Thanks for your help.


" Peter Olcott" < No **** @ SeeScreen.comwrote:
"Peter Olcott" <No****@SeeScreen.comwrote:
http://groups.google.com/group/comp=\"092f0f6c9bf13a


我认为operator []()成员函数不正常

正确,是否有其他人知道如何制作模板来制作

来自std :: vectors的二维数组?
http://groups.google.com/group/comp....092f0f6c9bf13a

I think that the operator[]() member function does not work
correctly, does anyone else know how to make a template for making
two dimensional arrays from std::vectors ?

http://www.parashift.com/c++-faq-lit...html#faq-13.10


我想使用普通数组[行] [COL]语法。
I want to use normal Array[ROW][COL] Syntax.



为什么?

Why?


这篇关于二维数组模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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