i have errors and i dont know y im gettin them here is the code. a majority of them are undeclaired idetifyers but they are function calls?!?!

#include <iostream>
#include <iomanip>

using namespace std;

class Array
{
	public:
			Array();
			Array(const Array& copyFrom);
			~Array() { };
			void append(int arrayA[]);
			void chop(int arrayA[]);
			void print(int arrayA[], int arrayB[], int arrayC []);
			void values(int arrayA[], int arrayB[], int *ptr);
			void is_equal(int arrayA[], int arrayB[], int arrayC[]);

	private:
		int add,
	   subtract;
};
			

void main()
{

	int arrayA[5] = {1,2,3,4,5},
		arrayB[7] = {1,2,3,4,5,0,0},
		arrayC[5] = {1,2,3,4,5};
	int copyFrom;

	Array();
	Array(Array& copyFrom);
	values(arrayA[5]);
	print(arrayA[5], arrayB[7], arrayC[5]);

	append(arrayA[5]);
	print(arrayA[5], arrayB[7], arrayC [5]);

	chop(arrayA[5]);

	print(arrayA[5], arrayB[7], arrayC[5]);
	cout << "Check to see if any array's are equal" << endl;

	is_equal(arrayA[5], arrayB[7], arrayC[5]);
}//main

Array::Array()
{
	int *ptr = 0;
}

Array::Array(const Array& copyFrom)
{
	int arrayA[5] = copyFrom.arrayA[5];

}// end copy

void Array::append(int arrayA[])
{

	cout<<"Enter the number you are inserting\n\n";
	cin>> add;

	cout << "We will insert " << add << " into Array A\n" << endl;

	arrayA[5-1] = add;
	
	
}//end append

void Array::chop(int arrayA[])
{
	cout << "Now we will delete that value from the Array" << endl;

	



}

void Array::values(int arrayA[], int arrayB[], int *ptr)
{
	 *this = arrayA[5];
	 *ptr = arrayB[7];
	 
}// end values

void Array::print(int arrayA[], int arrayB[], int arrayC [])
{
	cout << "Array A is: " << endl;
	for(int i = 0; i < 5; i++)
		cout << arrayA[i] << " ";
	cout << "\n\n";

	cout << "Array B is: " << endl;
	for(int j = 0; j < 7; j++)
		cout << arrayB[j] << " ";
	cout << "\n\n";

	cout << "Array C is: " << endl;
	for(int k = 0; k < 5; k++)
		cout << arrayC[k] << " ";
	cout << "\n\n";
}//print

 
void Array::is_equal(int arrayA[], int arrayB[], int arrayC[])
{
	

	for(int i = 0; i < 5; i++)
		cout << arrayA[i] <<  "  ";
	cout << endl;
		for(int j = 0; j < 7; j++)
			cout << arrayB[j] << "  ";
		cout << endl;

		if(arrayA[i] == arrayB[j])
			cout << "True" << endl;
		else
			cout << "False" << endl;



		for (i = 0; i < 5; i++)
			cout << arrayA[i] << "  ";
		cout << endl;
			for( j = 0; j < 5; j++)
				cout << arrayC[j] << "  ";
			cout << endl;

		if(arrayA[i] == arrayC[j])
			cout << "True" << endl;
		else
			cout << "False" << endl;
	
}

Array::~Array()
{
	delete arrayA;

}//destructor

Recommended Answers

All 12 Replies

void main()

That is the first problem -- it must be

int main()

Please identifiy other errors you are getting so that we don't have to compile your code. List some of the errors.

im gettin errors saying that the function calls in the main are undeclaired identifyers

Uh, you need some variable names here:

Array();
Array(Array& copyFrom);

like:

Array myArray;

here are the errors that im gettin with the part that it points to below it, some have arrows pointing to specific parts.

any help on these would be awsome cause i dont get y im gettin function calls as undeclaired identifyers

error C2275: 'Array' : illegal use of this type as an expression
see declaration of 'Array'
Array(Array& copyFrom);


error C2065: 'values' : undeclared identifier
values(arrayA[5]);


error C2065: 'print' : undeclared identifier
print(arrayA[5], arrayB[7], arrayC [5]);


error C2065: 'append' : undeclared identifier
append(arrayA[5]);


error C2065: 'chop' : undeclared identifier
chop(arrayA[5]);



error C2065: 'is_equal' : undeclared identifier
is_equal(arrayA[5], arrayB[7], arrayC[5]);


error C2039: 'arrayA' : is not a member of 'Array'
see declaration of 'Array'
Array::Array(const Array& copyFrom)
{
->    int arrayA[5] = copyFrom.arrayA[5];


}// end copy


error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
void Array::values(int arrayA[], int arrayB[], int *ptr)
{
->     *this = arrayA[5];
*ptr = arrayB[7];


}// end values
error C2084: function '__thiscall Array::~Array(void)' already has a body
Array::~Array()
-> {



}//destructor

1. Array() by itself if not a valid statement. If you want to create an object of type Array, then give it a name. The code snippet below instantiates an object of class Array and names is obj.

Array obj;

After you have named the object you can use its methods by stating the object name followed by a dot and then by the method name. Pay close attention to the function parameters -- their type must match the number of parameters and data type in the class description.

Array obj;
...
int aptr;
obj.values(arrayA, arrayB, &aptr);

Most of the errors you posted seem to be pretty clear about what is wrong. The error gives you the line number and what is wrong. Look at the code and you should be able to determine the cause of the error. Youre compiler's documentation will also normally give you a more elaborate explaination of the error number.

ok so after lookin up a couple other function programs i did i found out that it was somethin stupid i forgot so dont worry about thoes errors now the only errors im gettin are

'values' : cannot convert parameter 1 from 'int' to 'int []'

for example but im gettin that same thing for every function. i never understand these errors

and this one

error C2084: function '__thiscall Array::~Array(void)' already has a body

my first time using destructors so i dunno what that means

1. Array() by itself if not a valid statement. If you want to create an object of type Array, then give it a name. The code snippet below instantiates an object of class Array and names is obj.

Array obj;

After you have named the object you can use its methods by stating the object name followed by a dot and then by the method name. Pay close attention to the function parameters -- their type must match the number of parameters and data type in the class description.

Array obj;
...
int aptr;
obj.values(arrayA, arrayB, &aptr);

Most of the errors you posted seem to be pretty clear about what is wrong. The error gives you the line number and what is wrong. Look at the code and you should be able to determine the cause of the error. Youre compiler's documentation will also normally give you a more elaborate explaination of the error number.

yea thats what i found i did wrong when i looked back

but man i didnt know i have something that explains errors more how do i get tp the compiler documentation?

It appears that you may be using Microsoft Visual C++ -- all their errors are explained at www.msdn.microsoft.com. Just enter the error number in the search block.

error C2084: function '__thiscall Array::~Array(void)' already has a body

That means the destructor has already been coded, either as an inline function in the header file or in the implementation file. In your case it was already defined in the header. If you want it in the implementation file you have to remove the braces shown in RED below.

~Array() { };

When the function requires an array, all you have to do is put the array's name in the parameter list, as shown in main() in this code snipet.

int foo( int array[] )
{
  // do something
}

int main()
{
   int array[10];
   foo(array);
}

wow that error thing made my life so much easier thanks

ok now it compiles and links fine and everything but im getting an error when it runs from microsoft saying that it encountered a problem and has to close??

#include <iostream>
#include <iomanip>

using namespace std;

class Array
{
	public:
			Array();
			//Array(const Array& copyFrom);
			~Array() { };
			void append(int arrayA[]);
			void chop(int arrayA[], int subtract);
			void print(int arrayA[], int arrayB[], int arrayC[]);
			void values(int arrayA[], int arrayB[], int *ptr, int *p);
			void is_equal(int arrayA[], int arrayB[], int arrayC[]);

	private:
		int add,
	   subtract;
};
			

void main()
{

	int arrayA[5] = {1,2,3,4,5},
		arrayB[7] = {1,2,3,4,5,0,0},
		arrayC[5] = {1,2,3,4,5};
	int //copyFrom,
		*ptr = 0,
		subtract = 0,
		*p = 0;

	Array nums;
	Array();
	//Array(Array& copyFrom);
	nums.values(arrayA, arrayB, ptr, p);
	nums.print(arrayA, arrayB, arrayC);
	nums.append(arrayA);
	nums.print(arrayA, arrayB, arrayC);
	nums.chop(arrayA, subtract);
	nums.print(arrayA, arrayB, arrayC);

	cout << "Check to see if any array's are equal" << endl;

	nums.is_equal(arrayA, arrayB, arrayC);
}//main

Array::Array()
{
	int *ptr = 0;
	int	*p = 0;
}

/*Array::Array(const Array& copyFrom)
{
	int arrayA[5] = copyFrom.arrayA[5];

}// end copy
*/
void Array::append(int arrayA[])
{

	cout<<"Enter the number you are inserting\n\n";
	cin>> add;

	cout << "We will insert " << add << " into Array A\n" << endl;

	arrayA[5-1] = add;
	
	
}//end append

void Array::chop(int arrayA[], int subtract)
{
	subtract = NULL;
	cout << "Now we will delete that value from the Array" << endl;

	arrayA[5] = subtract;

}

void Array::values(int arrayA[], int arrayB[], int *ptr, int *p)
{
	 *ptr = arrayA[5];
	 *p = arrayB[7];
	 
}// end values

void Array::print(int arrayA[], int arrayB[], int arrayC [])
{
	cout << "Array A is: " << endl;
	for(int i = 0; i < 5; i++)
		cout << arrayA[i] << " ";
	cout << "\n\n";

	cout << "Array B is: " << endl;
	for(int j = 0; j < 7; j++)
		cout << arrayB[j] << " ";
	cout << "\n\n";

	cout << "Array C is: " << endl;
	for(int k = 0; k < 5; k++)
		cout << arrayC[k] << " ";
	cout << "\n\n";
}//print

 
void Array::is_equal(int arrayA[], int arrayB[], int arrayC[])
{
	

	for(int i = 0; i < 5; i++)
		cout << arrayA[i] <<  "  ";
	cout << endl;
		for(int j = 0; j < 7; j++)
			cout << arrayB[j] << "  ";
		cout << endl;

		if(arrayA[i] == arrayB[j])
			cout << "True" << endl;
		else
			cout << "False" << endl;



		for (i = 0; i < 5; i++)
			cout << arrayA[i] << "  ";
		cout << endl;
			for( j = 0; j < 5; j++)
				cout << arrayC[j] << "  ";
			cout << endl;

		if(arrayA[i] == arrayC[j])
			cout << "True" << endl;
		else
			cout << "False" << endl;
	
}
int main()
{

	int arrayA[5] = {1,2,3,4,5},
		arrayB[7] = {1,2,3,4,5,0,0},
		arrayC[5] = {1,2,3,4,5};
	int //copyFrom,
		*ptr = 0,
		subtract = 0,
		*p = 0;

	Array nums;
	Array();<<<DELETE THIS!
	//Array(Array& copyFrom);
	nums.values(arrayA, arrayB, ptr, p);<<this is wrong

The last two parameters to values function must be pointer to an integer, not an int pointer. values() is attempting to change the value to which the pointer points, but you sent it a NULL pointer that references a non-existant memory address.

int a, b;
	nums.values(arrayA, arrayB, &a, &b);
int main()
{

	int arrayA[5] = {1,2,3,4,5},
		arrayB[7] = {1,2,3,4,5,0,0},
		arrayC[5] = {1,2,3,4,5};
	int //copyFrom,
		*ptr = 0,
		subtract = 0,
		*p = 0;

	Array nums;
	Array();<<<DELETE THIS!
	//Array(Array& copyFrom);
	nums.values(arrayA, arrayB, ptr, p);<<this is wrong

The last two parameters to values function must be pointer to an integer, not an int pointer. values() is attempting to change the value to which the pointer points, but you sent it a NULL pointer that references a non-existant memory address.

int a, b;
	nums.values(arrayA, arrayB, &a, &b);

i thought that values call was wrong but i was not sure thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.