You can of course create a valarray<Inspector> object, but:
- if the
Inspector has no default arguments:
You must immediately indicate these arguments and amounts:
valarray<Inspector> inspactorData(Inspector(arg1, arg2,...), 10);
then you get inspactorData with 10 Inspector(arg1, arg2,...) objects Inspector(arg1, arg2,...) , which you can then replace with others.
- If the Inspector still has a default constructor, then:
you can create an object
valarray<Inspector> inspactorData;
but then you have to set the size (how many objects are supposed to contain)
inspactorData.resize(10); inspactorData[0] = Inspector(chNameDep, chTown, chRegion, chStreet, iBuilding, chNameInsp, chSurnameInsp, chPatronymicInsp, chPosition, chRank, iAge);
So you can fill in every element of the valarray object. All his operators lead to the call of the operators of the elements valarray . So your attempts to add using the + operator result in the fact that you summarize the objects contained in the sequence with another object, which is not what you expect, and secondly, your class may not have the definition of operator+
But valarray optimized for numerical methods, for other purposes it is simply undesirable to use it, and sometimes even lead to a dead end. So specifically for your class, better use containers ("not quite a kiteyner": this gave valarray the Stroustrup class)