COM SCI 31 Lecture Notes - Lecture 17: Init, Undefined Behavior, Null Pointer
Document Summary
Struct target public: // any part of the program can use init, move and replayhistory. Target(); // a constructor . no arguments, automatically called when an object is created bool move(char dir); void replayhistory() const; //only functions allowed to manipulate. // history can only have rs and ls. Target t; / automatically calls target fcn, initializes t. pos and t. history. // t. pos += 17; won"t compile! can"t change private member. // cout > c; if (! t2. move(c)) // if t2 doesn"t return true. good bc it tests the function move. Target* targets[100]; // 100 uninitialized pointers to targets int ntargets = 0; targets[ntargets] = new target; // tells os to make space for a new.