How do I define and statically initialize a vector index by an enumeration?
I'm unable to define a vector using an enumeration as an index.
First I define my record:
type contact_name is record
first : unbounded_string;
last : unbounded_string;
end record;
I define my enumeration:
type profession is (plumber, doctor, lawyer, ombudsman, dealer);
I declare my vector of contact_name using professional as the index type:
package Pro_Vector is new Ada.Containers.Vectors (Index_Type => Profession, Element_Type => contact_name);
Finally, I build my table:
Pro_Table : Pro_Vector.Vector := (plumber, ("Bob","daPlumah")) &
(doctor, "Felix", "FeelGood"))
When I try to compile it says expect signed integer type of Index_Type. It also claims Pro_Vector is undefined. I substituted profession for natural and it compiled, but my static initialization has errors.
Why won't it accept my enum as an index. I was under the impression that Ada is super safe. By using an unconstrained type like Natural, doesn't it compromise safety. Also, how do I statically initialize my vector?