www.digitalmars.com         C & C++   DMDScript  

D - Classes and Structs

reply "Nathan Matthews" <nedthefed nospam.hotmail.com> writes:
What is the difference between a class and a struct, can structs have member
methods?
If they do is the difference that they are not virtual?  Are structs
reference counted?

Whats the true size of a struct,

E.g. if we have

struct test
{
    int a, b;
    void func() {};
}

whats the sizeof test 8 bytes or 16 bytes?
Aug 16 2001
parent "Sheldon Simms" <sheldon semanticedge.com> writes:
Im Artikel <9lgpjv$2bnb$1 digitaldaemon.com> schrieb "Nathan Matthews"
<nedthefed nospam.hotmail.com>:

 What is the difference between a class and a struct, can structs have
 member methods?
Read the doc... Structs, Unions They work like they do in C, with the following exceptions: ... * Member functions and static members are not allowed. Structs and unions are meant as simple aggregations of data, or as a way to paint a data structure over hardware or an external type. ... Object oriented features are provided with the class data type. -- Sheldon Simms / sheldon semanticedge.com
Aug 16 2001