[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] / [CSci202] / 12
[Text Version] [Syllabus] [Schedule] [Glossary] [Resources] [Grading] [Contact] [Question] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] <12> [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Mon May 9 14:13:38 PDT 2011


    CS202 session 12 -- Overloading operators

      Previous -- linked data structures

      [ 11.html ]

      Warning -- Do Not Study Chapter 13 until later

      You can do some of this material in class 18 and the rest is part of CSCI330.

      Preparation -- Chapter 14 on Operator Overloading

      Study Chapter 14 and do Review Questions.

      Hint -- input output operators

      These are very helpful but the syntax is a mess. As a result ALWAYS copy/paste the header from a working example and modify it to fit the new class. I do not want you to waste time memorizing this syntax. It will not be on any quizzes or the final. However you do need to be able to remember what it means if I give you a correct example.

      Here is the source code for this chapter
      (Fractions): [ fraction.cpp ] [ fraction.h ] [ fractiontest.cpp ]

      Makefile for fractions:

         fractiontest: fractiontest.cpp fraction.h fraction.o
         	g++ -w -o fractiontest fraction.o fractiontest.cpp
         fraction.o: fraction.h fraction.cpp
         	g++ -w -c fraction.cpp

      (Matrices): The first cut [ matrix1.cpp ] [ matrix1.h ] [ matrixtest1.cpp ]

      Due in

      Hand in one even numbered question+answer at the start of class.

      Hand in what you have four Project 2, and project 1 resubmit.

      Class Work

        [ 12q.html ]

      Quiz 3

      Chapter 10,11,12, algorithm, P2

      Next -- Memories are made of this

      [ 13.html ]

      Next project due on class 17. Next quiz in class 17.

      Enrichment -- C++ Classes and abstract algebra

      Mathematicians have pointed out to me that the C++ language allows you to define implementations of abstarct algebra. For example, a group might have a definition like this
       class Group
             Group operator+(Group other);
             static Group zero();
             Group operator-();
      BUT -- this is only try if the operator are implemented to follow the axioms that define a group --
      1. For all a,b,c:Group
      2. For 0:=Group.zero().
      3. a+(b+c) == (a+b)+c.
      4. a+0 == a.
      5. a+(-a) == 0.
      6. ...
      [ maths/math_34_Groups.html#Motivation ]


  1. accessor::=`A Function that accesses information in an object with out changing the object in any visible way". In C++ this is called a "const function". In the UML it is called a query.
  2. Algorithm::=A precise description of a series of steps to attain a goal, [ Algorithm ] (Wikipedia).
  3. class::="A description of a set of similar objects that have similar data plus the functions needed to manipulate the data".
  4. constructor::="A Function in a class that creates new objects in the class".
  5. Data_Structure::=A small data base.
  6. destructor::=`A Function that is called when an object is destroyed".
  7. Function::programming=A selfcontained and named piece of program that knows how to do something.
  8. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular and free C++ compiler.
  9. mutator::="A Function that changes an object".
  10. object::="A little bit of knowledge -- some data and some know how". An object is instance of a class.
  11. objects::=plural of object.
  12. OOP::="Object-Oriented Programming", Current paradigm for programming.
  13. Semantics::=Rules determining the meaning of correct statements in a language.
  14. SP::="Structured Programming", a previous paradigm for programming.
  15. STL::="The standard C++ library of classes and functions" -- also called the "Standard Template Library" because many of the classes and functions will work with any kind of data.
  16. Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
  17. Q::software="A program I wrote to make software easier to develop",
  18. TBA::="To Be Announced", something I should do.
  19. TBD::="To Be Done", something you have to do.
  20. UML::="Unified Modeling Language".
  21. void::C++Keyword="Indicates a function that has no return".