Thread: C++ Template Class

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    16

    C++ Template Class

    Alright, I have an assignment in C++. I need to create a template class for imaginary expressions of the form a+bi and consider the following:

    Default Constructor
    Copy Constructor
    Destructor
    Assignment Operator
    +=
    *=
    +
    -
    *,[(a+bi)*(c+di)=(ac-bd)+(ad+bc)i]
    ==
    !=
    <<

    I want ot make sure I have the header and implementation for the class correct and to see how some other people would go about doing it. All necessary functions are already defined for the template class. I also want to know if any of the preceding don't need to be included in the class definition. Thanks in advance. I would also appreciate any links to C++ sites

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    52
    Operators used in a templated, user-defined class must be overloaded.

    >>I want ot make sure I have the header and implementation for
    the class correct ...
    It is normal for you to post an example of your code if you are
    asking for assistance.

    >> and to see how some other people would go about doing it.
    Textbooks provide examples of class templates, but please post some code and someone will help you out.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    16
    Thanks for some response, I did overload the operators. I figured out most of the problem and will post some of the code later on today if I have time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. template and friend class
    By black_spot1984 in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2008, 05:50 PM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  3. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  4. Instantiating a template class
    By NullS in forum C++ Programming
    Replies: 11
    Last Post: 02-23-2005, 10:04 AM
  5. Function template in Class template?
    By Aidman in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2003, 09:50 AM