templates, generic data types

This is a discussion on templates, generic data types within the C++ Programming forums, part of the General Programming Boards category; I want to have a class that uses generic data types. i want it to be able to use a ...

  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, 11:13 AM
  2. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 04: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, 06:45 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21