How to avoid default constructor when creating an array of objects?
<p>I'm totally new here, so I'm not very familiar with style of writing here, so sorry if the question doesn't look like it should.
My question is, how can I create an array of object, but not with default constructors?
If I have something like this:</p>

<pre><code>set&lt;movie&gt; a(3);
set&lt;movie&gt; b(2);
</code></pre>

<p>And constructors:
For movie </p>

<pre><code>movie::movie()
{
    this-&gt;naziv=0;
    this-&gt;reditelj=0;
    this-&gt;trajanje=0;
}

movie::movie(char *name, char *red, int len)
{
    this-&gt;naziv=new char[strlen(name)+1];
    strcpy(naziv,name);
    this-&gt;reditelj=new char[strlen(red)+1];
    strcpy(reditelj,red);
    this-&gt;trajanje=len;
}
</code></pre>

<p>And for set:</p>

<pre><code>template&lt;class t&gt;
set&lt;t&gt;::set()
{
    this-&gt;br=0;
    this-&gt;niz=0;
}

set&lt;t&gt;::set(int b)
{
    this-&gt;br=b;
    this-&gt;niz=new t[br];
}
</code></pre>

<p>Answers are great,but on course they teach us some basic stuff about c++,how to create class,template class,I mean,to write programs from the beginning,so for now we don't use that classes and functions that most of you mentioned. The assignment is to write the code this way,so how can I do that?
The assignment is to make a class and a template class,template class is actually an array of objects,so I should make an object,that's an array of objects,and some other functions.</p>

<p>Here's my whole code:</p>

<p>Set.h</p>

<pre><code>#pragma once
#include&lt;iostream&gt;
using namespace std;

template&lt;class t&gt;
class set
{
    int br;
    t* niz;
public:
    set();
    set(int b);
    ~set();
    set(set&amp; copy);
    int vrati_br_elem()
    {
        return br;
    }
    bool pripada(t elem);
    set operator*(set&amp; drugi);
    friend istream&amp; operator&gt;&gt; &lt;&gt;(istream&amp; ulaz,set&lt;t&gt; &amp;s);
    friend ostream&amp; operator&lt;&lt; &lt;&gt;(ostream&amp; izlaz,set&lt;t&gt; &amp;s);
};

template&lt;class t&gt;
set&lt;t&gt;::set()
{
    this-&gt;br=0;
    this-&gt;niz=0;
}

template&lt;class t&gt;
set&lt;t&gt;::set(int b)
{
    this-&gt;br=b;
    this-&gt;niz=new t[br];
}

template&lt;class t&gt;
set&lt;t&gt;::~set()
{
    if(this-&gt;niz!=0)
        delete [] niz;
}

template&lt;class t&gt;
bool set&lt;t&gt;::pripada(t elem)
{
    for(int i=0;i&lt;this-&gt;br;i++)
        if(this-&gt;niz[i]=elem)
            return true;
    return false;
}

template&lt;class t&gt;
set&lt;t&gt; set&lt;t&gt;::operator *(set&lt;t&gt; &amp;drugi)
{
    int broj=0;
    set&lt;t&gt; pom((this-&gt;br&gt;drugi.br)?this-&gt;br:drugi.br);
    for(int i=0;i&lt;this-&gt;br;i++)
        for(int j=0;j&lt;drugi.br;j++)
            if(this-&gt;niz[i]==drugi.niz[j])
                pom.niz[broj++]=this-&gt;niz[i];
    pom.br=broj;
    return pom;
}

template&lt;class t&gt;
istream&amp; operator&gt;&gt;(istream&amp; ulaz,set&lt;t&gt; &amp;s)
{
    for(int i=0;i&lt;s.br;i++)
        cin&gt;&gt;s.niz[i];
    return ulaz;
}

template&lt;class t&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; izlaz,set&lt;t&gt; &amp;s)
{
    for(int i=0;i&lt;s.br;i++)
        cout&lt;&lt;endl&lt;&lt;s.niz[i]&lt;&lt;endl;
    return izlaz;
}

template&lt;class t&gt;
set&lt;t&gt;::set(set&lt;t&gt; &amp;copy)
{
    this-&gt;br=copy.br;
    this-&gt;niz=new t[br];
    for(int i=0;i&lt;this-&gt;br;i++)
        this-&gt;niz[i]=copy.niz[i];
}
</code></pre>

<p>movie.h</p>

<pre><code>#include&lt;iostream&gt;
using namespace std;

class movie
{
    char* naziv;
    char* reditelj;
    int trajanje;
public:
    movie();
    ~movie();
    movie(movie&amp; copy);
    movie(char* name,char* red,int len);
    movie&amp; operator=(movie&amp; film);
    bool operator==(movie&amp; film);
    friend istream&amp; operator&gt;&gt;(istream&amp; ulaz,movie&amp; film);
    friend ostream&amp; operator&lt;&lt;(ostream&amp; izlaz,movie&amp; film);
};
</code></pre>

<p>movie.cpp</p>

<pre><code>#include"movie.h"
using namespace std;

movie::movie()
{
    this-&gt;naziv=0;
    this-&gt;reditelj=0;
    this-&gt;trajanje=0;
}

movie::~movie()
{
    if(naziv!=0&amp;&amp;reditelj!=0)
    {
        delete [] naziv;
        delete [] reditelj;
    }
}

movie::movie(movie &amp;copy)
{
    this-&gt;naziv=new char[strlen(copy.naziv)+1];
    strcpy(this-&gt;naziv,copy.naziv);
    this-&gt;reditelj=new char[strlen(copy.reditelj)+1];
    strcpy(this-&gt;reditelj,copy.reditelj);
    this-&gt;trajanje=copy.trajanje;
}

movie&amp; movie::operator =(movie &amp;film)
{
    if(this!=&amp;film)
    {
        delete [] naziv;
        delete [] reditelj;

        this-&gt;naziv=new char[strlen(film.naziv)+1];
        strcpy(this-&gt;naziv,film.naziv);
        this-&gt;reditelj=new char[strlen(film.reditelj)+1];
        strcpy(this-&gt;reditelj,film.reditelj);
        this-&gt;trajanje=film.trajanje;
    }
    return *this; 
}

bool movie::operator ==(movie &amp;film)
{
    if(!strcmp(this-&gt;naziv,film.naziv)&amp;&amp;!strcmp(this-&gt;reditelj,film.reditelj)&amp;&amp;this-&gt;trajanje==film.trajanje)
        return true;
    return false;
}

istream&amp; operator&gt;&gt;(istream&amp; ulaz,movie&amp; film)
{
    ulaz&gt;&gt;film.naziv&gt;&gt;film.reditelj&gt;&gt;film.trajanje;
    return ulaz;
}

ostream&amp; operator&lt;&lt;(ostream&amp; izlaz,movie&amp; film)
{
    izlaz&lt;&lt;endl&lt;&lt;film.naziv&lt;&lt;endl&lt;&lt;film.reditelj&lt;&lt;endl&lt;&lt;film.trajanje&lt;&lt;endl;
    return izlaz;
}

movie::movie(char *name, char *red, int len)
{
    this-&gt;naziv=new char[strlen(name)+1];
    strcpy(naziv,name);
    this-&gt;reditelj=new char[strlen(red)+1];
    strcpy(reditelj,red);
    this-&gt;trajanje=len;
}
</code></pre>
