Ah, yes, I see...that's what happened. I'm traditionally a Java developer, so I forget about things like that in C++. I ran the code in debug mode the second time. No problem now - the code's just as fast as it was before. Thanks for all the help!
Alright, so the problem's solved. Apparently, the fact that all template declarations needed to be in the header file was the only problem. I didn't REBUILD the code, I only BUILT it, and that's why my changes had no effect at first. I rebuilt the code, and it worked. Now the other problem...
Could anyone tell me how, if at all, templates and generics affect code speed. I know that it depends on the kind of code, but my main question is whether using templates instead of actually having an implementation for each type, slows down the code at all. Or is all the work done at compile...
That doesn't fix anything though...I've even tried shoving all the code into a single file, but that still doesn't fix anything. It looks like it doesn't understand that this:
allocate2DArray <unsigned char> (100, 100);
is trying to access this:
template <class T>
GenericArray2DStruct<T>*...
I'm having a problem getting templates to work in a program. I haven't used them for a while, so maybe I'm confused somehow as to how to use them correctly. I looked it up and it seems that I have the right syntax though. I do not get a compile error. I get a linker error. I'm using Deviant...
So here I am running regular C code that looks like this:
(I am new to these forums and don't know how to do the code box, I'll try my best)
<code>
#include <stdio.h>
#include <stdlib.h>
#define xImageSize 435
#define yImageSize 383
typedef struct {
unsigned char** data...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.