Thread: objects

  1. #16
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    the <> brackets are used after the type name when declaring an object of a class in STL because the container classes in STL are all templated classes. If you want your Hash class to act like the STL classes then look into how to make it a templated class.
    You're only born perfect.

  2. #17
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Those are templates, I don't know if you can override that operator.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  3. #18
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    the <> brackets...I don't know if you can override that operator.
    It's not an operator.

  4. #19
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by 7stud
    It's not an operator.
    Sorry, thanks for the correction.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  5. #20
    Registered User
    Join Date
    Mar 2005
    Posts
    16
    ok this is kind of getting over my head but to make it so you can declare
    Code:
    Hash <int> myHash; //is this correct syntax? something like this, anyway
    you have to use templates, which are classes that can work with any variable types. that is not overloading. search google, or there is a template tutorial on cprogramming.com

  6. #21
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I think you mean defining your own operators:
    Code:
    class Complex
    {
      public:
        Complex
        {
          Re = 0.0;
          Im = 0.0;
        }
    
        const Complex& operator =(double NewRe)
        {
          Re = NewRe;
          Im = 0.0;
    
          return *this;
        }
    
      private:
        double Re;
        double Im;
    }
    The code makes it possible to type:
    Code:
    Complex c;
    c = 3.14;
    instead of:
    Code:
    Complex c;
    c.Re = 3.14;
    c.Im = 0.0;
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. most efficient way to write filestream objects?
    By darsunt in forum C++ Programming
    Replies: 3
    Last Post: 01-26-2009, 05:17 PM
  2. Replies: 60
    Last Post: 12-20-2005, 11:36 PM
  3. Question about cout an stack object?
    By joenching in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2005, 10:10 PM
  4. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM
  5. array of objects?
    By *~*~*~* in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 05:57 PM