[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] >> [CSci201] >> [Lab01] >> index
[Index] [Schedule] [Syllabi] [Glossary] [Labs] [Projects] [Resources] [Grading] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Tue Feb 12 14:16:14 PST 2008

Contents


    CSci201 Lab/07 -- The size of C++ Data Types

      Why Learn about Pointers?

       Hello Dr. Concepcion,
       I just had an personal interview with XXXX. Everything went well. Yyyy
       was much easier to talk to in person. I did the test well (one of the
       interviewer said)
       The test was mainly pointers. Thanks to Dr Botting, he trained me good
       with pointer in csci320.
       There was one 6-part question that I scored 5 out of 6. They said no one
       ever get them all right.
       The test format was extremely unusual. It asked "what would happen if
       .." and doesn't give you a clue what
       they expect the format of the answers would be.

      A simple Pointer example

      Download and figure out the following program. [ pointer.cpp ]

      Add commants explaining what is going on inside the program.

      Sizes of data

      Here is a C++ program [ sizes.cpp ] for you to download and work with. It has one line that needs removing.

      The sizeof operator calculates the number of bytes of storage the compiler allocates to the operand.

      The ".size()" will tell you the number of items currently in a vector or string.

      Fix any compilation errors and make it run.

      Questions

      1. Why was there a compile error?
      2. Do all pointer types (T*) need the same storage?
      3. Does the size of a pointer (T*) reflect the size of thing pointed at(T)?
      4. Does the size of an array vary with the number of elements?
      5. Does the sizeof a vector vary with the number of elements?
      6. Does the size() a vector vary with the number of elements?

      To answer the questions you might want to make some more changes.

      Deliverable

      Add comments to the porogram explaining in your own words what is going on.

      Deadline

      I will be assigning grades at the end of the lab depending on how much of the deliverables are complete and correct.

    Abreviations

  1. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular C++ compiler.
  2. TBA::="To Be Announced", something I have to do.
  3. TBD::="To Be Done", something you have to do.

End