473,320 Members | 1,922 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,320 software developers and data experts.

initilization of composite types

Given a composite type such that:

struct tp2
{
unsigned int val1;
tp2 ()
: val1(0)
{}
};

And yet again another composite type that's is comprised of the the one
above.

struct tp1 {
unsigned int val2;
tp2 tp;
tp1()
: val2(0)
{}
};

Besides the fictious names, thats the general constructs for messaging
between my different systems.

What's interesting to me though is the fact that if I transfer tp1
between a source and destination, the struct tp2 in tp is
'unitialized'. In other words, val1 in tp2 is 'non zero' ( some
FFFFFF nonesense). This leads me to believe the initilzation of val1
in tp2 is not getting honored which is puzzling.

So I take it a step futher. So now:

struct tp1 {
unsigned int val2;
tp2 tp;
tp1()
: val2(0)
, tp() //<-- lets initialize tp here.
{}
};

This works out better. i.e val1 is now zero. This approach though
suggest that I'm initializing tp twice. Yes/No?

I'm using gcc 2.96 ( which I'm forced to live with for now ) but I'm
just trying to get a feel for why the first option didn't work out.

I suspect in this day and age, what I need to do is something akin to:

struct tp2
{
unsigned int val1;
tp2 ( int v )
: val1(v)
{}
};

struct tp1
{
unsigned int val2;
tp2 tt;
tp1 ( const tp2& t, int v )
: tt(t)
, val2 ( v )
{}
};

Feb 12 '06 #1
0 1143

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

Similar topics

0
by: AshifToday | last post by:
this was my and my frineds little project in earlier classes, the program seperates the composite and prime numbers in two sections of the screen ===================== /* This program has...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
6
by: puzzlecracker | last post by:
Why would this work? - and it does! any thoughts? #include<stdio.h> void init(char **str){ *str="Awesome"; } main(){
5
by: vsnadagouda | last post by:
Hello All, I am looking for some way to delay the global variable initilization. To make myself more clear, here is a simple example: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
0
by: Ivan Sergio Borgonovo | last post by:
I'd like to compute some "row like" results and return them from a function (and pass the result to PHP). Well I've read about composite type but all the references I've seen are about coding in...
2
by: pkpatil | last post by:
Hi, Can a private composite object in a class access private or protected members of base class? For e.g. class composite { void memberFunction(); };
14
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or...
1
by: ma740988 | last post by:
Consider the source snippet. # include <iostream> struct foo_struct { int odx ; int pdx ; foo_struct () : odx ( 0 ) , pdx ( 0 )
4
by: Wolfgang Keller | last post by:
Hello, so far it seems to me as if the only ORM module for Python which supports composite primary/foreign keys was SQLAlchemy. Which looks a little bit "overbloated" for my needs: I "just" need...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.