ITP 165
Introduction To C++
Week 7

Terms And Buzzwords:

  1. Class - One type of user-defined object. A class is composed of 2 main parts, data members and member functions. In addition, these 2 parts are divided into Public members and Private members. A tybpical class will contain at least 2 constructors, the default constructor and a copy constructor.
  2. Constructor - A special function that is used to initialize data members when a class object is instantiated (declared). If, for example, an object of the class foo is declared in the following format:
    foo x;
    The default constructor is called. Additional constructors can take arguments. Calling on these constructors takes the following form:
    foo x([argument list]);
    Finally, copy constructors are used to copy data from one class to another.
  3. Freind - Any function or object that has been given permission to access private members of a class. A friend declaration is made within the class definition, but not defined within the scope of a class.
  4. Data Member - a variable that exists within the scope of the class.
  5. Member Function - a function that exists within the scope of the class, having access to all data members of that class.
  6. Operator Overloading - A means by which operators (i.e., +, -, &&, =, etc ad nauseum) can be redefined in terms of the class. It is very common to overload the = operator to give a means of translating other objects and native data types into that class.
  7. Private - a "tag" used to mark which members of a class can not be accessed outside of the class. Private members are accessible to friends. Entire classes may also be declared private.
  8. Public - a "tag" used to mark which members of a class can be accessed outside of the class. Public members are accessible to everybody. Entire classes are typically declared public.

Sample Class Declaration:

class foo
{

public:
foo(); //default constructor
foo(const foo &); //copy constructor
foo(int, int); //constructor that takes input arguments

void bar(); //Public Member Function
void bar(int, int); //Public member function that takes input arguments

foo &operator=(int); //Overloaded operator

private:
int x, y, z; //Private Data Members
}

 

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees