OpenArray (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example is a console application that uses open arrays.

Code

#pragma hdrstop

#include <tchar.h>
#include <System.hpp>
#include <stdio.h>
// ---------------------------------------------------------------------------

#pragma argsused

class TElement {
public:
	int Data;
};

void foo(TElement* e, int high) {
	for (int i = 0; i <= high; i++) {
		printf("%d\n", e[i].Data);
	}
}

int _tmain(int argc, _TCHAR* argv[]) {
	TElement e1;
	TElement e2;
	e1.Data = -20;
	e2.Data = -40;
	foo(OPENARRAY(TElement, (e1, e2)));
	return 0;
}
// ---------------------------------------------------------------------------

Uses