Thursday, 26 May 2011

C++ program part2

  1. What are instance variables?
    These represent an object's private memory. They are defined in an object's class.

  2. What are class variables?
    These represent a class's memory which it shares with each of its instances.

  3. What is a method?
    A method is a class's procedural response to a given message protocol. It is like the definition of a procedure in other languages.

  4. In C++ what is a constructor? A destructor?
    A constructors and destructors are methods defined in a class that are invoked automatically when an object is created or destroyed. They are used to initialize a newly allocated object and to cleanup behind an object about to be removed.

  5. Compare and contrast C and C++.
    Comparison: C++ is an extension to the C language. When C++ is used as a procedural language, there are only minor syntactical differences between them.
    Contrast: When used as a procedural language, C++ is a better C because:
    • It vigorously enforces data typing conventions.
    • It allows variables to be defined where they are used.
    • It allows the definition of real (semantically significant) constants.
    • It allows for automatic pointer dereferencing.
    • It supports call-by-reference in addition to call-by-value in functions.
    • It supports tentative variable declarations (when the type and location of a variable cannot be known before hand.
    As an object oriented language, C++ introduces much of the OOP paradigm while allowing a mixture of OOP and procedural styles.
  6. What is operator overloading?
    It is the process of, and ability to redefine the way an object responds to a C++ operator symbol. This would be done in the object's class definition.

  7. What is cin and cout?
    They are objects corresponding to a program's default input and output files.

No comments:

Post a Comment