This does not look right:
Code:
heltal::heltal(int nmr)
{
nmr = tal;
}
void heltal::setValue(int value, int nmr)
{
nmr = value;
}
The constructor should assign nmr to tal, and not tal to num.
The second function does not do anything useful as it operates upon only its arguments nmr and value... and since the variables are passed by value, calling the function has no effect on the passed in parameters. You probably mean to assign something to tal but that's just a guess. There should also probably be only one argument to this function.
Your comparison operators make no sense, unless I'm just not seeing something:
Code:
class heltal
{
...
heltal operator< (heltal &heltal);
heltal operator> (heltal &heltal);
};
...
heltal operator< (heltal tal, heltal value)
{
tal = value;
return tal;
}
heltal operator> (heltal tal, heltal value)
{
value = tal;
return value;
}
These functions should return a bool (true/false) value. The function should be const like your getValue function and they should accept a const reference to the heltal object being compared against. You should also change the variable names to be something other than the same name as the type itself. Lastly, your header and source files are saying different things about what arguments these functions should expect. If I were writing these I'd do something like this:
Code:
class heltal
{
...
bool operator< (const heltal &rhs) const;
bool operator> (const heltal &rhs) const;
};
...
bool heltal::operator< (const heltal& rhs) const
{
return tal < rhs.tal;
}
bool heltal::operator> (const heltal& rhs) const
{
return tal > rhs.tal;
}
Code:
class Array
{
...
int generate_numbers(int arraysize, int high, int low)
{
...
There is no reason you should need to include the arraysize argument for this function. Once the Array object is created it already knows its size. This size is stored in the object's arraysize member and does not need to be passed into the function... just use it in the function's code.
Code:
ptrHeltal[x] = (rand() % high + low);
First, assuming high and low are meant to be ranges for your random numbers, you are calculating this range incorrectly. A range of random values in the interval from low..high should be calculated as rand() % (high - low + 1) + low.
Second, after the Array class constructor has run, it has already constructed its heltal members during its calling of operator new. At this point in the code, to assign this value to the heltal member you should use the heltal object's setValue member function.
Other issues may exists beyond what I've pointed out.