Saturday, 15 February 2014

class - C++ program crashing (has something to do with with dynamic memory) -


I'm getting crispy, which happens every time that every state starts to undefine for the loop. Is there such a thing that the light can shine? #include #include #include Namespace std;

  class MyPhoneBook {public: MyPhoneBook (int, string, string, string, string); MyPhonebook (); ~ MyPhonebook (); Zero start (int, int, string, string, string, string); Bull search (string and, int); Bool find_free_pos (); Add Zero (); Zero removal (); Zero performance; Friend's First & amp; Operator & gt; & Gt; (Istream and In, MifonBook and PH); Dost Ostream & amp; Operator & lt; & Lt; (Ostream & amp; Out, MyFonbook and PH); Private: int * recordid; Int * position; // -1 is no longer on this number, 0 is blocked, 1 is not blocked, 2 free string * names, * escodes, * numbers, * groups; }; Int main (int argc, char ** argv) {cout & lt; & Lt; "Test 1" & lt; & Lt; Endl; MyPhoneBook * myphbk; // pointer which will point to an object of the mifonbook category myphbk = new MyPhoneBook [100]; // Now it uses dynamic memory cout & lt; & Lt; "Test 2" & lt; & Lt; Endl; // just for the input pause = 0; [Myphbk [pos] .initialize (start positioning for (1 + 1), 2, (pos = 0; pos & lt; 100; pos ++) // to undefined everything, Undefined "," undefined "," undefined ");} Cout & lt;" test3 "& lt; endl; // for testing bus only) return 0 ; Zero MyPhoneBook :: initialise (int recordid_, int status_, string name_, string areacode_, string number_, string group_) {// now specify them in the private member variable * recordid = recordid_; * position = position_; * name = name_ ; * Isacode = i Sacode_; * number = number_; * group = group_; // end of assignment}  

No one knows why my program can not be reached in the cout & lt; & lt ; "Exam 3" & lt; & lt; the end of the program without crashing?

The constructor of MyPhoneBook was not pasted, but there could be problems

  * recordid = recordid_; * Position = position_;  

If you have not created a valid address for recordid and status , then

< Code> recordid = new int; Condition = new int;

You may want to declare those member variables as a simple int .


No comments:

Post a Comment