| | |
free(): invalid pointer error need help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
When i compile my code i keep getting an error. *** glibc detected *** ./main: free(): invalid pointer: 0xbfb82c34 *** . I can not figure out for the life of me what the issue is. I think it may have something to do with my constructor. Any suggestions would be appreciated.
C++ Syntax (Toggle Plain Text)
Employee* Earray[10]; // Declared as private member of payroll Payroll::Payroll() { Employee **EmpPointer; EmpPointer = new Employee*[10]; for ( int i = 0; i < 10; i++ ) { Earray[i] = 0; } } Payroll::~Payroll() { delete [] Earray; }
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
Ok i figured out the error, it had to do with my destructor. The program compiles now but it is not working the right way. I believe i am trying to declare a 2-D array when i want to do a 1-D one but it's the only way i could get the code to compile. For my code i am supposed to have a Payroll class that will contain a fixed size array of pointers to Employee. The array must be processed polymorphically. Constructor: Creates Payroll with no employees.
Destructor: Cleans up as the object leaves scope. The Employee class is an Abstract Base Class. Here is my constructor.
Destructor: Cleans up as the object leaves scope. The Employee class is an Abstract Base Class. Here is my constructor.
C++ Syntax (Toggle Plain Text)
Employee* Earray[10]; //Declared private member in Payroll Payroll::Payroll() { Employee **EmpPointer; EmpPointer = new Employee *[10]; }
![]() |
Similar Threads
- Problem with linked queue (C++)
- Queue Linked Car Wash Assignment (C++)
- Cannot find server or DNS Error - please help! (Viruses, Spyware and other Nasties)
- free(): invalid pointer error - Help! (C++)
- Crazy Leak...plz help (C++)
- c++ invalid pointer.... (C++)
- Sorted linked list help (C++)
Other Threads in the C++ Forum
- Previous Thread: Multi-Tasks & Multi-Threads Concepts Under Windows! Help
- Next Thread: Circular shifts, bits distorted/missing?
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker 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 rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






