printf() uses a format string to get its arguments... I was just trying to get rid of any need for that.
Type: Posts; User: LPP
printf() uses a format string to get its arguments... I was just trying to get rid of any need for that.
Is this possible? I thought I had seen this sort of thing somewhere, but I can't find it or replicate it. This is my attempt:
void example(int notimportant, ..., int terminator = 0)
Thought...
I meant private as in hidden code-wise, public-vs-private etc., and it's not working. I'll try the stuff again, but... -yawn-
Ok, so, when I said it all worked, now it's kinda not. Because of it all being in the .cpp, for some reason, it is saying that every global variable in the .cpp (except for the templates) are...
Not at all. Linker Errors abound, for every single call.
However, having the main include the .cpp makes it all work!
Now how can I keep those thing private that I want kept private?
Ok... following the articles' (which I read and now fully understand) instructions, I "plunked" my template code into the .h and took it out from the .cpp
The .h includes the .cpp, the .cpp...
Including the templated stuff I want kept private? Also, what about stuff in the source referencing the templated functions and objects? There's a lot more code to this than I posted up...
Any combination of those doesn't work, unless I'm still not doing it right. Is there a sample? Just show me how to do it in relation to what I posted and I'll try it.
So, am I hearing that I should put the templates in their own header file, or put them in a separate .cpp and include that, or that I should include the templated functions in the existing .h?
Ahah! But the user specifies a single struct that contains all the data they need for the end function. It looks like I am going to have to do a bit of void* manipulation, but I'm not sure how it...
I opted to try out templates... To see how that went (heh) check out my thread about the linker error. I'll try out the void* solution now, see how that goes... I'm optimistic, except for memory...
So, I'll just toss some example code at you to start:
This is the struct and its constructor:
template <class type_s> struct task {
double time;
void (*task)(type_s);
type_s...
Thanks! iostream, huh? A little odd.
Well, the problem that I'm having is in my header file... If I declare a function that takes an optional argument of NULL, it says NULL was not declared in this scope. What exactly does that mean?
The name pretty much says it all. How do you do it, specifically in header files?
Well, you've shown that I can't do it through malloc, and I also can't use formatting strings or a null marker to signal the end of a va_list because I need to keep it in that form until it gets to...
Another thing... Where should the va_end be called in my example (assuming there were no pointer issues)? Should it be called in the constructor, or in the end function?
Excellent! Thank you... I had never really understood this. I already have several uses for this.
So, a pointer issue... Would I be able to, say, malloc arugments to keep that from happening? (Don't hurt me!)
Can't have that... I need to allow the user to input a variable number of...
Just wondering if anyone has solid advice on when and how to use typedef.
So, I have a function that accepts a variable number of arguments and va_start's a va_list. It then creates a struct, assigns that va_list to one of the members, and then stores that struct...
And there is no option, other than va_arg?
On an entirely different note, can I create argument lists as variables and then pass them to a function, ie:
void function(int a, int b){define...
Thanks very much! That was just a dumbed-down example of what I had. Ready for the next one?
Can I have a function like so:
void arg_func(...)
Where I use the va_ functions to dissect...
Is it possible to have function pointers in structs and classes? Here is the structure of the code I am trying to write:
struct function_pointer
{
int id;
int...