View Single Post
May 11th, 2004
0

Re: Return Array from C++

C++ is not my native tongue, but I'll mention a couple of things and try to wade through the linter's output.

First, I believe you are trying to delete the objects twice. Once in main(), and then again in the destructor when the object goes out of scope.

[edit1]
C++ Syntax (Toggle Plain Text)
  1. if ( index < 0 || index >= LENGTH )
  2. cout << "INVALID INDEX" << endl;
  3. array[index] = value;
Here you may attempt to access out of array bounds.
[/edit1]

[edit2]
 Array()
{
	 array = new int(LENGTH);
}
I think you want the square brackets.
 Array()
{
	 array = new int[LENGTH];
}
[/edit2]

[edit3]
Lint:
Quote ...
[Info 1732] new in constructor for class 'Array' which has no assignment operator
[Info 1733] new in constructor for class 'Array' which has no copy constructor
I forget why, but it's right.
[/edit3]
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004