// Syntax: // Comment for reader's benefit, not parsed // # Template Number - +100 for each new type of problem, +10 for each new subtype // Learning Objective(s) for this template - when this template should be used // ? // If student gets the answer right, what OTHER objectives should get credit // Usually, counterpoint to the point of the error, say allocation for missing // deallocation, Declaration for out of scope error, assignment for incorrect // referencing, etc. // Make sure there is no overlap between this and antecedents! // : // If student gets the answer wrong, what OTHER objectives should get discredit // Make sure there is no overlap between this and antecedents! // > // The template itself, no double quotes, preceded and succeeded by a single > // > // Type: debug / output / code / expression // Hardness: The student's correct percentage up to which this template will be used // Note: Syntax for learning objectives (in antecedent, ifCorrect, ifWrong) // is dot.separated, with {,} to represent alternates. // e.g., a.{b,c} is a.b and a.c // This is NOT graph structured, i.e., a,{b,c}.d is not accounted for to mean // a.b.d or a.c.d // dangling pointer // indirect addressing // dereference before initializing # 211-217 // dereferencing after variable to which it points goes out of scope // without re-assignment # 201-204 // with re-assignment // same name // 2 levels - DO // different names // 2 levels - DO // dynamic memory // dereferencing before allocating - ignore // dereferencing after deleting # 250-253 // lost object # 501-509 // indirect addressing // allocate, then assign to a variable // dynamic memory // allocate, then allocate // // # 101 - 104 // Pointer.Declaration.scope.Accessing pointer out of scope // # 211 - 217 // Pointer.Dereferencing.Dereferencing pointer before initializing/allocating // # 201 - 204 // Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope // # 250 - 253 // Pointer.Dereferencing.Dereferencing pointer after the anonymous variable to which it points is deallocated // # 301 - 304 // Pointer.{Dereferencing.Correct,Deallocation.Correct} // # 311 - 314 // Pointer.Dereferencing.Correct // # 401 - 404 // Pointer.Dereferencing // # 501 - 509 // Pointer.Deallocation.No pointer pointing to the anonymous variable // # 411 - 414 // Pointer.Anonymous Variable.Referencing.Referencing anonymous variable before initializing its value // Pointer - Accessing pointer out of scope // Technically, students can also say variable accessed outside scope // - ambiguous - used in Spring 2004 // # 101 // Pointer.Declaration.scope.Accessing pointer out of scope // ? // Pointer.Declaration.{Correct,scope.Correct} // > // {(){{;=;=&;}<<;}} // > // Type: debug // Hardness: 100 // Technically, students can also say variable accessed outside scope // - ambiguous, used in Spring 2004 // # 102 // Pointer.Declaration.scope.Accessing pointer out of scope // ? // Pointer.Declaration.{Correct,scope.Correct} // > // {(){{=;;=&;}<<;}} // > // Type: debug // Hardness: 100 // Although this is correct, it is confusing to students // - 5 instances of students answering this incorrectly on post-test // even after solving out of scope problems correctly on practice // in Spring 2004 - so discarding // # 104 // Pointer.Declaration.scope.Accessing pointer out of scope // ? // Pointer.Declaration.{Correct,scope.Correct} // > // {(){=;{=;;{=&;}}<<;}} // > // Type: debug // Hardness: 100 // ---------------------------------------------------------------------------- # 101 Pointer.Declaration.scope.Accessing pointer out of scope ? Pointer.Declaration.{Correct,scope.Correct} > {(){=;{;=& ;}<<;}} // {(){=;{*;= &;}<<*;}} > Type: debug Hardness: 100 # 102 Pointer.Declaration.scope.Accessing pointer out of scope ? Pointer.Declaration.{Correct,scope.Correct} > {(){=;{;{= & ;}}<<;}} > Type: debug Hardness: 100 # 103 Pointer.Declaration.scope.Accessing pointer out of scope ? Pointer.Declaration.{Correct,scope.Correct} > {(){=;{;= &;<<;}{;= &;}<<;}} > Type: debug Hardness: 100 # 104 Pointer.Declaration.scope.Accessing pointer out of scope ? Pointer.Declaration.{Correct,scope.Correct} > {(){=;{;= &;}<<;{;= &;<<;}}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- // Pointer - Dangling Pointer # 201 Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope ? Variable.Declaration.{Correct,scope.Correct} > {(){;{=;= &;}<<;}} > Type: debug Hardness: 100 // lame // # 202 // Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope // ? // Variable.Declaration.{Correct,scope.Correct} // > // {(){;{=;{= &;}}<<;}} // > // Type: debug // Hardness: 100 # 203 Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope ? Variable.Declaration.{Correct,scope.Correct} > {(){;=;{=;= & ;}<<;<<;}} > Type: debug Hardness: 100 # 204 Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope ? Variable.Declaration.{Correct,scope.Correct} > {(){=;{;{=;= & ;}<<;}<<;}} > Type: debug Hardness: 100 // Re-assignment, different names - 2 levels of nesting # 205 Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope ? Variable.Declaration.{Correct,scope.Correct} > {(){;=;= &;{=;= &;<<;}<<;}} > Type: debug Hardness: 100 // Re-assignment, same name - 2 levels of nesting # 206 Pointer.Dereferencing.Dereferencing pointer after the variable to which it points goes out of scope ? Variable.Declaration.{Correct,scope.Correct} > {(){;=;= &;{=;= &;<<;}<<;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- # 211 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating > {(){;=;<<;= & ;}} > Type: debug Hardness: 100 # 212 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating > {(){=;;<<;= & ;}} > Type: debug Hardness: 100 # 213 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating ? Pointer.Declaration.scope.Correct > {(){;{=;<<;= & ;}}} > Type: debug Hardness: 100 # 214 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating ? Variable.Declaration.scope.Correct > {(){=;{;<<;= & ;}}} > Type: debug Hardness: 100 # 215 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating ? Pointer.Declaration.scope.Correct > {(){;{<<;=;= & ;}}} > Type: debug Hardness: 100 # 216 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating ? Pointer.Declaration.scope.Correct > {(){;<<;{=;= & ;}}} > Type: debug Hardness: 100 # 217 Pointer.Dereferencing.Dereferencing pointer before initializing/allocating > {(){;<<;=;= & ;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- # 250 Pointer.Dereferencing.Dereferencing pointer after the anonymous variable to which it points is deallocated > {(){;=new();<<;delete;<<;}} > Type: debug Hardness: 40 # 251 Pointer.Dereferencing.Dereferencing pointer after the anonymous variable to which it points is deallocated > {(){;=new;delete;<<;}} > Type: debug Hardness: 40 # 252 Pointer.Dereferencing.Dereferencing pointer after the anonymous variable to which it points is deallocated > {(){;{=new();<<;delete;}<<;}} > Type: debug Hardness: 40 # 253 Pointer.Dereferencing.Dereferencing pointer after the anonymous variable to which it points is deallocated > {(){;{=new();<<;delete;}=;<<;<<;}} > Type: debug Hardness: 40 // ---------------------------------------------------------------------------- // Pointer - Code OK # 301 Pointer.{Dereferencing.Correct,Deallocation.Correct} ? Pointer.{Declaration.Correct,Allocation.Correct} > {(){;=new();<<;delete;}} > Type: debug Hardness: 100 # 302 Pointer.{Dereferencing.Correct,Deallocation.Correct} ? Pointer.{Declaration.{Correct,scope.Correct},Allocation.Correct} > {(){;{=new();<<;}delete;}} > Type: debug Hardness: 100 # 303 Pointer.{Dereferencing.Correct,Deallocation.Correct} ? Pointer.{Declaration.{Correct,scope.Correct},Allocation.Correct} > {(){;{=new();}<<;{delete;}}} > Type: debug Hardness: 100 # 304 Pointer.{Dereferencing.Correct,Deallocation.Correct} ? Pointer.{Declaration.{Correct,scope.Correct},Allocation.Correct} > {(){;=new();{<<;}delete;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- # 311 Pointer.Dereferencing.Correct ? Pointer.{Declaration.{Correct,scope.Correct},Assignment.Correct} > {(){;{=;= & ;<<;}}} > Type: debug Hardness: 100 # 312 Pointer.Dereferencing.Correct ? Pointer.{Declaration.Correct,Assignment.Correct} : Pointer.{Declaration.Correct,Assignment.Correct,Dereferencing.Correct,Deallocation.Correct} > {(){=;{;= & ;<<;}}} > Type: debug Hardness: 100 # 313 Pointer.Dereferencing.Correct ? Pointer.{Declaration.Correct,Assignment.Correct} > {(){;=;= & ;<<;}} > Type: debug Hardness: 100 # 314 Pointer.Dereferencing.Correct ? Pointer.{Declaration.Correct,Assignment.Correct} > {(){=;;= & ;<<;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- // Pointer - Semantic Error # 401 Pointer.Dereferencing ? Variable.Referencing.Referencing variable before initializing its value : Variable.Referencing.Correct > {(){;;= & ;<<;}} > Type: debug Hardness: 100 # 402 Pointer.Dereferencing ? Variable.Referencing.Referencing variable before initializing its value : Variable.Referencing.Correct > {(){;{;= & ;<<;}}} > Type: debug Hardness: 100 # 403 Pointer.Dereferencing ? Variable.Referencing.Referencing variable before initializing its value : Variable.Referencing.Correct > {(){;{;= & ;<<;}}} > Type: debug Hardness: 100 # 404 Pointer.Dereferencing ? Variable.Referencing.Referencing variable before initializing its value : Variable.Referencing.Correct > {(){;;{= & ;}<<;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- # 411 Pointer.Anonymous Variable.Referencing.Referencing anonymous variable before initializing its value ? Pointer.Anonymous Variable.Referencing.Correct > {(){;=new;<<;delete;}} > Type: debug Hardness: 100 # 412 Pointer.Anonymous Variable.Referencing.Referencing anonymous variable before initializing its value ? Pointer.{Anonymous Variable.Referencing.Correct,Declaration.scope.Correct} > {(){;{=new;<<;}delete;}} > Type: debug Hardness: 100 # 413 Pointer.Anonymous Variable.Referencing.Referencing anonymous variable before initializing its value ? Pointer.{Anonymous Variable.{Referencing.Correct,scope.Correct},Declaration.scope.Correct} > {(){;{=new;}<<;{delete;}}} > Type: debug Hardness: 100 # 414 Pointer.Anonymous Variable.Referencing.Referencing anonymous variable before initializing its value ? Pointer.{Anonymous Variable.Referencing.Correct,Declaration.scope.Correct} > {(){;=new;{<<;}delete;}} > Type: debug Hardness: 100 // --------------------------------------------------------------------------------- // // Lost object on return from main() - not a good template // // Pointer - Lost Objects // # 501 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.Allocation.Correct // > // {(){;=new();<<;}} // > // Type: debug // Hardness: 100 // // // Lost object on return from main() - not a good template // # 502 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.{Declaration.scope.Correct,Allocation.Correct} // > // {(){;{=new();<<;}}} // > // Type: debug // Hardness: 100 // // // Lost object on return from main() - not a good template // # 503 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.{Declaration.scope.Correct,Allocation.Correct,Anonymous Variable.scope.Correct} // > // {(){;{=new();}<<;}} // > // Type: debug // Hardness: 100 // // // OK, but silly distractor // # 504 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.Allocation.Correct // > // {(){{;=new();<<;}=;<<;}} // > // Type: debug // Hardness: 100 # 505 Pointer.Deallocation.No pointer pointing to the anonymous variable ? Pointer.Allocation.Correct > {(){=;{;=new();<<;}<<;}} > Type: debug Hardness: 100 // // Lost object on return from main() - not a good template // # 506 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.Allocation.Correct // > // {(){;=new();{;=new();<<;}<<;}} // > // Type: debug // Hardness: 100 // Good problem # 507 Pointer.Deallocation.No pointer pointing to the anonymous variable ? Pointer.{Allocation.Correct,Assignment.Correct} > {(){;=;= & ;{;=new();<<;}<<;}} > Type: debug Hardness: 100 // // Lost object on return from main() - not a good template // # 508 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.{Allocation.Correct,Assignment.Correct} // > // {(){;=new();{;=;= & ;<<;}<<;}} // > // Type: debug // Hardness: 100 // // // allocate, re-allocate, but second anonymous object still lost upon exiting main // # 509 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.{Allocation.Correct,Assignment.Correct} // > // {(){;=new();= new( + );<<;}} // > // Type: debug // Hardness: 100 // allocate, re-assign # 510 Pointer.Deallocation.No pointer pointing to the anonymous variable ? Pointer.{Allocation.Correct,Assignment.Correct} > {(){;=;=new();<<;= & ;<<;}} > Type: debug Hardness: 100 // allocate, re-allocate # 511 Pointer.Deallocation.No pointer pointing to the anonymous variable ? Pointer.{Allocation.Correct,Assignment.Correct} > {(){;=new();<<;= new();<<;delete ;}} > Type: debug Hardness: 100 // ---------------------------------------------------------------------------- // Make this work after making pointer assignments possible // // allocate, re-allocate // # 512 // Pointer.Deallocation.No pointer pointing to the anonymous variable // ? // Pointer.{Allocation.Correct,Assignment.Correct} // > // {(){;=;=new();<<;{; = ; = & ;}<<;}} // > // Type: debug // Hardness: 100 # 999 Pointer.Dereferencing ? Variable.Referencing.Correct > {(){=;{; = ;= & ;<< * + * ;}}} > Type: debug Hardness: 100 // ------------------------------------------------------------------------------ // Templates used for the trial run // Intentionally do not provide correct learning objectives, // so that trial run does not affect student's learning objectives // Semantic error # 90 Demonstration > {(){;<<;}} > Type: debug Hardness: 10 // Code OK # 91 Demonstration > {(){=;{<<;}}} > Type: debug Hardness: 10 // Syntax error # 92 Demonstration > {(){{;}<<;}} > Type: debug Hardness: 10