|
-
Oct 12th, 2002, 03:50 AM
#1
Thread Starter
Hyperactive Member
-
Oct 12th, 2002, 03:54 AM
#2
Monday Morning Lunatic
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
-
Oct 12th, 2002, 03:55 AM
#3
Thread Starter
Hyperactive Member
I can use templates, but i don't know how
-
Oct 12th, 2002, 04:08 AM
#4
Monday Morning Lunatic
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
-
Oct 12th, 2002, 04:12 AM
#5
Thread Starter
Hyperactive Member
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:
T* stor;
};
template <class T>
void CObjectStorage<T>::Alloc(int size)
{
//using
};
-
Oct 12th, 2002, 05:56 AM
#6
transcendental analytic
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.
-
Oct 12th, 2002, 08:32 AM
#7
Thread Starter
Hyperactive Member
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... (
-
Oct 12th, 2002, 08:34 AM
#8
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.
-
Oct 12th, 2002, 09:12 PM
#9
Thread Starter
Hyperactive Member
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)
-
Oct 12th, 2002, 10:44 PM
#10
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|