abstract structs

  • Thread starter Thread starter Dirk Reske
  • Start date Start date
D

Dirk Reske

hello,

I have following problem:

I have a struct "MainStruct"
now I want to build structs which all "starts" with MainStruct.

struct1
{
MainStruct var;
anotherStruct var2;
}

struct2
{
MainStruct var;
AnotherStruct2 var2;
}

......is there a way to do this?
And how can I declare a method, which accepts all structs which a derived
from MainStruct as argument?

I hope you have understood all (I'm from Germany)
 
I have a struct "MainStruct"
now I want to build structs which all "starts" with MainStruct.

struct1
{
MainStruct var;
anotherStruct var2;
}

struct2
{
MainStruct var;
AnotherStruct2 var2;
}

.....is there a way to do this?
And how can I declare a method, which accepts all structs which a derived
from MainStruct as argument?

It doesn't work this way. You could reach what you want using inheritance
but structs doesn't support inheritance you should use a class instead.
I hope you have understood all (I'm from Germany)

Ich denk' schon :)
 
lol....sind doch ganz schön viele deutsche drin:-)
hatt ich schon oft

codymanix said:
I have a struct "MainStruct"
now I want to build structs which all "starts" with MainStruct.

struct1
{
MainStruct var;
anotherStruct var2;
}

struct2
{
MainStruct var;
AnotherStruct2 var2;
}

.....is there a way to do this?
And how can I declare a method, which accepts all structs which a derived
from MainStruct as argument?

It doesn't work this way. You could reach what you want using inheritance
but structs doesn't support inheritance you should use a class instead.
I hope you have understood all (I'm from Germany)

Ich denk' schon :)

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
 
but when I do:

struct1
{
....
}

struct2 : struct1
{
newMember;
}

where in memory are the new mebers?
behind the members of struct1 or in front of it?
this is, because its a class I use to P/Invoke a Win32 call.
I need it so:

MembersOfBaseClass
MembersOfDerivedClass

Dirk Reske said:
lol....sind doch ganz schön viele deutsche drin:-)
hatt ich schon oft

codymanix said:
I have a struct "MainStruct"
now I want to build structs which all "starts" with MainStruct.

struct1
{
MainStruct var;
anotherStruct var2;
}

struct2
{
MainStruct var;
AnotherStruct2 var2;
}

.....is there a way to do this?
And how can I declare a method, which accepts all structs which a derived
from MainStruct as argument?

It doesn't work this way. You could reach what you want using inheritance
but structs doesn't support inheritance you should use a class instead.
I hope you have understood all (I'm from Germany)

Ich denk' schon :)

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
 
lol....sind doch ganz schön viele deutsche drin:-)
hatt ich schon oft

Liegt auch einfach daran das die deutschen newsgroups zum kotzen sind. Wenn
du keinen Realname verwendest, deine Rechtschreibung nicht perfekt ist oder
was auch immer, dann wirs du gleich dumm angemacht.
 
The new members are always behind the the members of the base-class in
memory but as already pointed out you have to use classes, not structs.

The exact position and alignment of the members in memory are not defined
and should not be of interest for you.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk

Dirk Reske said:
but when I do:

struct1
{
...
}

struct2 : struct1
{
newMember;
}

where in memory are the new mebers?
behind the members of struct1 or in front of it?
this is, because its a class I use to P/Invoke a Win32 call.
I need it so:

MembersOfBaseClass
MembersOfDerivedClass

Dirk Reske said:
lol....sind doch ganz schön viele deutsche drin:-)
hatt ich schon oft

codymanix said:
I have a struct "MainStruct"
now I want to build structs which all "starts" with MainStruct.

struct1
{
MainStruct var;
anotherStruct var2;
}

struct2
{
MainStruct var;
AnotherStruct2 var2;
}

.....is there a way to do this?
And how can I declare a method, which accepts all structs which a derived
from MainStruct as argument?

It doesn't work this way. You could reach what you want using inheritance
but structs doesn't support inheritance you should use a class instead.

I hope you have understood all (I'm from Germany)

Ich denk' schon :)

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
 
Back
Top