Results 1 to 10 of 10

Thread: Container

  1. #1

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394

    Arrow Container

    Hi

    I am trying to develop a management class and store any type of class within. I think its possible using interfaces.

    Is that possible to do without templates?
    VS.NET 2003

    Need to email me?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Without templates? Why not? If you really can't use them, then you can use polymorphism and have all the objects you store in it deriving from a single class, then storing pointers.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    I can use templates, but i don't know how
    VS.NET 2003

    Need to email me?

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    www.bruceeckel.com -- Thinking in C++. I think it's Volume 2 that goes into templates...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    Thanks for your reply

    I already have abook on templates in C++... but i dont understand them


    Can you tell me whats wrong with this?

    PHP Code:
    template <class T>
    class 
    CObjectStorage  
    {
    public:
        
    void Alloc(int);
    private:
        
    Tstor;

    };

    template <class T>
    void CObjectStorage<T>::Alloc(int size)
    {
        
    //using
    }; 
    VS.NET 2003

    Need to email me?

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    compiles fine for me, maybe you're using a compiler that doesn't support templates well? templates are used for polymorphism but without the overheads, and are all set during compiletime
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    I am using MSVC 6.0

    It compiles but doesnt link when i try to actually use it:

    CObjectStorage<int> a;
    a.Alloc(10);

    above ^^^^ doesnt work... (
    VS.NET 2003

    Need to email me?

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What linker error?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    This comes up:

    --------------------Configuration: Interfacing - Win32 Debug--------------------
    Linking...
    Interfacing.obj : error LNK2001: unresolved external symbol "public: void __thiscall CObjectStorage<int>::Alloc(long)" (?Alloc@?$CObjectStorage@H@@QAEXJ@Z)
    Debug/Interfacing.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Interfacing.exe - 2 error(s), 0 warning(s)
    VS.NET 2003

    Need to email me?

  10. #10
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Are the actual member functions in a separate .cpp? If that is the case, paste them into the header, and remove the .cpp from the project, and try it again.

    Z.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width