| | |
Errors help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
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?!?!
C++ Syntax (Toggle Plain Text)
#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"; 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
C++ Syntax (Toggle Plain Text)
void main()
C++ Syntax (Toggle Plain Text)
int main()
Please identifiy other errors you are getting so that we don't have to compile your code. List some of the errors.
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
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
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.
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.
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.
C++ Syntax (Toggle Plain Text)
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.
C++ Syntax (Toggle Plain Text)
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.
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
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
'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
•
•
Join Date: Mar 2005
Posts: 91
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by Ancient Dragon
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.
C++ Syntax (Toggle Plain Text)
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.
C++ Syntax (Toggle Plain Text)
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.
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.
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.
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.
C++ Syntax (Toggle Plain Text)
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);
}![]() |
Similar Threads
- Simple Programming Errors (Computer Science)
- confused with errors in c++ (C++)
- Windows XP and Corel Suite 8 (WP8) errors (Windows NT / 2000 / XP)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Errors during scandisk (Windows 95 / 98 / Me)
- Upgrading Xp Home to Pro - ERRORS! (Windows NT / 2000 / XP)
- strange annoying errors (Windows NT / 2000 / XP)
- w2k server errors (Windows NT / 2000 / XP)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: help me in my project to be submitted january 9, 2006
- Next Thread: How to "delete" this memory???
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






