473,800 Members | 2,614 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does this mean in C++ AType(Ptr)[index]

SGi
I wonder if anyone here knew Pascal before C++, perhaps you could help me
out. I'm converting some pascal code into C++, and I can't seem to
understand what AType(Ptr)[index] is trying to accomplish. Any helps would
be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

Jun 2 '06
11 2213
SGi
> Another one! What makes you think that "Move(AType(Ptr )[index], .."
is not a C++ expression. For all I know about C++, that expression
surely looks like C++. I just explained what it is in C++. Did you
think otherwise? What gave you that idea?


Move((void*)sta tic_cast<BYTE*> (Ptr)[index], &w, 2);
Almost pure C++...
Jun 2 '06 #11
Victor Bazarov wrote:
Rolf Magnus wrote:
Victor Bazarov wrote:
mlimber wrote:
SGi wrote:
> I wonder if anyone here knew Pascal before C++, perhaps you could
> help me out. I'm converting some pascal code into C++, and I can't
> seem to understand what AType(Ptr)[index] is trying to accomplish.
> Any helps would be appreciated. Thanks.
>
> type
> AType = array[0..$FF] of byte;
>
> var Ptr : Pointer;
>
> Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked
in a more appropriate forum. See this FAQ for what is on-topic here
and for some possible forums you can post in:

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

Cheers! --M

Don't just the gun, M. In the expression

Move(AType(Ptr)[index], ...

The part

AType(Ptr)[index]

is an explicit type conversion from 'Ptr' to 'AType' ("functional
notation") and then applying of the indexing operator to it.


Maybe that's the case. I don't know Pascal. Anyway, since we're not
in a Pascal group, this is off-topic.


Another one! What makes you think that "Move(AType(Ptr )[index], .."
is not a C++ expression.
For all I know about C++, that expression
surely looks like C++. I just explained what it is in C++. Did you
think otherwise? What gave you that idea?


The OP. He wanted some Pascal code converted to C++ and wanted to know how
to do that for a specific piece of code. And that piece was:
> type
> AType = array[0..$FF] of byte;
>
> var Ptr : Pointer;
>
> Move(AType(Ptr)[index], dest_word, 2);


So what gave you the idea that the last line is supposed to be C++? Just
that it looked like C++? Where would he get that line from without knowing
what it means if he wants to convert Pascal code to C++?

Jun 3 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

97
27824
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
29
3986
by: Hagen | last post by:
Hello, in a recent thread "speed of vector vs array" I read about the problem of the slow acces by addressing vector elements by indexing, unfortunately I see no workaround in my case. My case: class A {
5
1739
by: Sid | last post by:
Hi, I was going through this reference code and playing around with it. The code (shown below) shows a class that represents a stack of string pointers In the code below in particular in the pop function, the code works when I set stack=0 but when I say delete stack the code compiles but does not execute -I am only trying to "delete stack" after I have copied the relevant data pointed by it into variable "rv", so why is this program...
2
1539
by: trying_to_learn | last post by:
im trying to index through an array that is member of a class using ptr to member in main i tried making a ptr to the member 'arr' : const int * testclass7::* ptrToMemberIntPtr = &testclass7::arr; ------------------------------------------------------ the compiler cries: cannot convert from 'int (testclass7::*)' to 'const int *testclass7::* ' Types pointed to are unrelated; conversion requires reinterpret_cast,
4
1099
by: qazmlp | last post by:
size_t len = strlen( myCString ) ; for( WHAT i = 0 ; i < len ; ++i ) { // iterate through the string // and do some operations }
4
2433
by: quek | last post by:
Im having a problem passing a struct ptr. Maybe someone could help me. Heres what Visual C gives me as error: error C2664: 'adpcm_coder_u' : cannot convert parameter 4 from 'struct main::$S1 *' to 'struct adpcm_state *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
72
3636
by: ravi | last post by:
I have a situation where i want to free the memory pointed by a pointer, only if it is not freed already. Is there a way to know whether the memory is freed or not?
19
14944
by: Jason | last post by:
Hello, could someone explain the difference to me inbetween: *ptr++ and ++*ptr Thankx a lot.. Jason.
89
5775
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the right thing to use for every var that holds the number of or size in bytes of things. * size_t should only be used when dealing with library functions.
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.