On 03/04/2012 01:35 PM, maarten van damme wrote:
> thank you for helping me out.
> I do not really understand why new File creates a pointer to a file object.
> does new struct() creates a pointer to that newly created struct?
>

Yes. new returns a pointer for structs and non-reference fundamental types. For reference types like classes and arrays, it returns a reference to the actual variable:

struct S
{}

class C
{}

void main()
{
    /* Value types */
    int * ip = new int;
    double * dp = new double;
    S * sp = new S;

    /* Reference types */
    C class_variable = new C;
    int[] slice = new int[10];
}

Ali

Reply via email to