This is an highly simplified case (it doesn't resize), but (I hope) addresses your specific construction question. If you are doing this for exercise you should start with something simpler, like a stack and read all the interesting nuance of exceptions guarantee (there is a beautiful analysis by Sutter on it).
#include <iostream>
#include <initializer_list>
#include <algorithm>
template <typename T>
class array
{
size_t size; //Size of current array
int items; //items currently in array
T *arr;
public:
//copy and moving semantic omitted
~array() { delete[] arr; }
//use initializer list available from C++11
array(std::initializer_list<T> init)
: size(init.size()),
items(init.size()),
arr(new T[init.size()])
{
std::copy(init.begin(), init.end(), arr);
}
//create an array with n elements of a specific value
array(size_t count, const T& value)
: size(count), items(count), arr(new T[count])
{
std::fill(arr, arr + count, value);
}
std::ostream& print(std::ostream& os) const
{
for (size_t i = 0; i < size; i++)
os << arr[i] << " ";
return os;
}
};
int main()
{
array<int> a({1,2,3,4,5,6,10});
a.print(std::cout);
array<double> b(5, -1.5);
b.print(std::cout);
}
Initializer list are supported from C++11.
Some articles:
https://www.stroustrup.com/except.pdf strong exception guarantee vector implementation.
https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/aw/meyerscddemo/DEMO/MAGAZINE/SU_FRAME.HTM Stack exception safety analysis (I remember the book version to be expanded compared to this article)
Please refer to this link for the rule of 0/3/5 What is The Rule of Three?
https://en.cppreference.com/w/cpp/language/rule_of_three
We did have to write the destructor so other (at least) two functions are due.