Thread: templates, generic data types

  1. #1
    Unregistered
    Guest

    Question templates, generic data types

    I want to have a class that uses generic data types. i want it to be able to use a struct, how do i create an instance of the class. i have tried:

    className<struct> name;

    but it doesnt work. any tips would be very helpful. i'm using the turbo C++ compiler for my program.

    Thanks heaps =)

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    139
    need more info....
    Do you want to use the struct in the class?
    Do you want to use a class in the struct?

    Code:
    #includes for classes and other dependencies
    struct MyStruct
    {
      My_Time_class My_time;
      int My_money;
    };
    
    int main()
    {
      MyStruct Peter;
      
      Peter.My_time.increment();
      return 0;
    }
    "The most common form of insanity is a combination of disordered passions and disordered intellect with gradations and variations almost infinite."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 03:28 PM
  3. What are abstract data types
    By bhagwat_maimt in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2007, 10:43 AM
  4. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM