15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Multidimensional Arrays

Tan V. Do -- tvd@spydr.com
Saturday, August 17, 1996

Environment: MSVC4.2, Windows95

Has anyone been able to implement a multidimensional array using the MFC
array classes like CArray.  I am trying to make a three dimensional array,
but the MFC classes have no = operator which causes some problems.  If
anyone has any experience, please reply.


					----- Tan V. Do -----
					--- tvd@spydr.com ---
					http:// www.spydr.com




Mike Blaszczak -- mikeblas@nwlink.com
Monday, August 19, 1996

[Mini-digest: 2 responses]

At 11:28 AM 8/17/96 -0500, you wrote:

>Has anyone been able to implement a multidimensional array using the MFC
>array classes like CArray.  I am trying to make a three dimensional array,
>but the MFC classes have no = operator which causes some problems.

They don't have an assignment operator because we wanted the classes to be
a little bit safer. It's too easy to invoke an assignment operator on a class
like CArray when you don't know it--and that could be an immensely expensive
operation.

I'm not sure why you want to use an operator=, but you can acchieve the same
effect using the Append() or Copy() members, depending on what exactly
it is you're doing.


.B ekiM
http://www.nwlink.com/~mikeblas   <--- trip report central
1995 Honda VFR750F (Serial number 00050!)  4 Corners 1996!
1987 Yamaha FZ700 (damaged)                AMA, HRC, VFROC
     These words are my own: I do not speak for Microsoft.

-----From: jimt1@voicenet.com (Jim Tannenbaum)

Tan,

        Back in the _Old_ days, we learned that you could always calculate
the offset into memory of an n dimensional array (something that the
compiler does for you) for a flat address space.  For example, take a 2-D
array (ExAry[ROW][COL]), the offset n = nRowIdx * ROW + nColIdx.  The array
can be declared as [ROW][COL] or [ROW * COL].  Either way, the same amount
of memory is used.  You could also overload the = operator using MFC, but I
believe in the KISS principle.

        Jet

JJM Systems, Inc                 Phone: (215) 672-3660
1 Ivybrook Blvd, Suite 190       Fax:   (215) 672-5702
Ivyland, PA  19874               Net:   jimt1@voicenet.com






| Вернуться в корень Архива |