Author |
Message |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu May 20, 2004 9:16 am Post maybe stupid Post subject: |
 |
|
|
|
Sorry, no idea. I don't use templates. You are off the hook.  _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu May 20, 2004 5:09 pm Post maybe stupid Post subject: |
 |
|
|
|
Yay.
If you don't use templates, how do you suggest doing what I'm doing? |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu May 20, 2004 6:30 pm Post maybe stupid Post subject: |
 |
|
|
|
My guess is to use void pointers.
Ekted doesn't strike me as the C++ type of person. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu May 20, 2004 10:39 pm Post maybe stupid Post subject: |
 |
|
|
|
A vector is an array of values. This can be done easily in C, without all the ridiculous template coding, rampant angle brackets, or plethora of functions. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri May 21, 2004 4:35 pm Post maybe stupid Post subject: |
 |
|
|
|
Yeah actually I was thinking in math class today that I mightn't as well use void pointers instead of a template. I'm no fan of templates myself, since they produce a ton of excess code.
Anyway, in conversion to void pointers, I've gotta learn how to use malloc right. When I allocate the memory for the objects that I'm gonna stash in the array, how do I tell the program how much it's gonna allocate? I can't use sizeof(), because that's generated on compile-time. Should I just pass the size as an argument?
News:
Well I started passing an object size as a parameter to the constructor... but VC++ complains about sizeof() being used in the header file where I'm using the vector. Huh?? |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun May 23, 2004 12:08 am Post maybe stupid Post subject: |
 |
|
|
|
Nevermind, I just went with the template, couldn't figure out how to call a constructor with malloc... guess it wasn't made to. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun May 23, 2004 10:29 am Post maybe stupid Post subject: |
 |
|
|
|
When you use malloc() to create an object it means you are choosing to use straight C. There are no constructors in C. There is nothing "hidden" that happens without you explicitly calling it. That's one of the reasons I like it so much. I hate the fact that "a = b;" in C++ can result in millions of lines of code being executed. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun May 23, 2004 12:10 pm Post maybe stupid Post subject: |
 |
|
|
|
OK, that's what I figured. And since I like constructors, I think I'll just stick with C++ stuff. Sorry  |
|
Back to top |
|
 |
|