So I have an assignment that says:
Please use generic instantiations of packages/classes. Space for each BMR (matrix) must be allocated in the system stack within the generic package/template, probably during generic instantiation! You specifically may not use "new,” “malloc,” or any other operator, which allocates space in the heap at runtime in any language. Clearly mark this section of your code with a highlighter! You must read all transactions and print all results within the generic package/template. The I/O routines must be passed as generic parameters
And unrelated code:
generic
type subscript is (<>); --range variable to be instantiated
type myType is private; --type variable to be intantiated
package genericArray is
type userDefinedArray is array(subscript range <>) of myType;
end genericArray;
with ada.text_io; use ada.text_io;
with genericArray;
procedure useGenericArray is
type month_name is (jan, feb, mar, apr, may, jun,
jul, aug, sep, oct, nov, dec);
type date is
record
day: integer range 1..31; month: month_name; year: integer;
end record;
type family is (mother, father, child1, child2, child3, child4);
package month_name_io is new ada.text_io.enumeration_io(month_name);
use month_name_io;
package IIO is new ada.text_io.integer_io(integer);
use IIO;
package createShotArrayType is new genericArray(family, date);
use createShotArrayType;
vaccine: userDefinedArray(family);
begin
vaccine(child2).month := jan;
vaccine(child2).day := 22;
vaccine(child2).year := 1986;
put("child2: ");
put(vaccine(child2).month);
put(vaccine(child2).day);
put(vaccine(child2).year); new_line;
end useGenericArray;
Again, the code posted has nothing to do with the assignment, but my question is that, in the code posted, is space being allocated in the stack or the heap every time I use the word "new". Because my directions say NOT to use this word, but then it says to use generic instantiation which requires it I think. I would appreciate clarification!