473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

overlay class over memory

I am relatively new to C++ so this is probably a basic question: Can I
overlay a class over a chuck of memory just like one can overlay a
struct over memory. I need to parse a frame comming from the network
hardware.

Thanks,

Piotr

Feb 26 '06 #1
5 3355
lr******@ftml.net wrote:
I am relatively new to C++ so this is probably a basic question: Can I
overlay a class over a chuck of memory just like one can overlay a
struct over memory. I need to parse a frame comming from the network
hardware.


You should take a look at "placement new".

V
--
Please remove capital As from my address when replying by mail
Feb 26 '06 #2

<lr******@ftml.net> schrieb im Newsbeitrag
news:11**********************@u72g2000cwu.googlegr oups.com...
I am relatively new to C++ so this is probably a basic question: Can I
overlay a class over a chuck of memory just like one can overlay a
struct over memory. I need to parse a frame comming from the network
hardware.


Only if your class looks like a classic struct. If you add "hidden"
varialbles to the class, e.g. a a pointer to the virtual function table do
to a virtual function in the class, ... it will mess up the memory
alignment.
Feb 26 '06 #3
Is placement new fixing the problem of virtual tables?

Piotr

Feb 26 '06 #4
lr******@ftml.net wrote:
Is placement new fixing the problem of virtual tables?


What book are you reading that doesn't explain 'new'? "Placement
new" is not different at all in the procedure of constructing the
object. The only difference is actual memory allocation, the
"regular" 'new' allocates, the "placement" doesn't.

V
--
Please remove capital As from my address when replying by mail
Feb 26 '06 #5
lr******@ftml.net wrote:
I am relatively new to C++ so this is probably a basic question: Can I
overlay a class over a chuck of memory just like one can overlay a
struct over memory. I need to parse a frame comming from the network
hardware.


Simply casting the memory *might* work except for alignment and byte order.

This is a posting I did a while ago - might help.

http://groups.google.com/group/comp....e4a6bda?&hl=en
Feb 26 '06 #6

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

Similar topics

0
by: Never Best | last post by:
I'm having troubles attaching the Device to a window using its hWnd, and I have some troubles with getting transparancy to work with a DDOverlay... if anyone could help it would be greatlay...
1
by: sendhil | last post by:
hi, Iam doing some graphics programming with C#. I have to create a Windows MetaFile from a base64 encoded string. How do i create the file. I want to Overlay this Windows MetaFile on a image...
0
by: odie5533 | last post by:
I am looking to make a program similar to Xfire which will overlay information while playing a directx game. For an example of what xfire is capable of, see the image below:...
3
by: kaczmar2 | last post by:
Hey there, I have a large image in a browser window, and I would like a way to overlay grid lines on top of the image, so a user can show the grid or hide the grid lines. The grid would cover...
9
by: Chuck Anderson | last post by:
Is it possible to overlay a transparent watermark on an image - dynamically? I'd like the result to look like this example: <http://www.cycletourist.com/temp/photo.php> That is a bit of...
1
by: Starkiss01 | last post by:
I am using this code to put a top banner on my site <div class="dhead"><img src=" http://img.photobucket.com/albums/v193/tbugz/fixed.gif "></div> </Style> <style type="text/css">...
2
by: pravinnweb | last post by:
i have dropdown select menu in my page. when i click any button the black overlay comes while loading. in FF overlay working fine but in IE the select option menu appeared on overlay...please help me
5
by: pravinnweb | last post by:
i have dropdown select menu in my page. when i click here link the black overlay comes .in FF overlay working fine but in IE6 the select option menu appeared on overlay...please help me thanks in...
1
by: linksterman | last post by:
I want to make a simple app to overlay subtitles on youtube videos. Is there a way to do this and keep the files hosted on youtubes servers (eg just overlay the text with another flash app)? I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...
0
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...

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.