Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C function call operator

Name: Anonymous 2012-04-21 8:23

How do I define the function call operator of a user defined type in C? Every site I google says the following:

MyType operator()(int arg1,int arg2,int etc){
MyType x;
x.nigger=buttsecs(arg1);
x.mature=whatever(arg2);
return x;
}


...but my compiler thinks I'm defining the typecast operator and says I have an incorrect number of arguments.
What I am trying to do is be able to call a variable of MyType as if it was a function. I can accomplish the same thing by defining the [] operator (or some other operator) instead and use that to call, but the problem here is I'm trying to define some sort of a hybrid type that can even take function pointers as arguments and return function pointers, and it will not always be obvious to myself whether I'm calling it with a function or another type and I want the () operator to contain code that handles that shit automatically.

This sounds convoluted but in a nutshell: I want to overload the call operator () as if any other operator (like []) but my compiler is trying to overload the typecast operator instead. Obviously my syntax is incorrect and I haven't guessed the correct syntax yet, so correct me.

If this is a sepples only thing like I fear, I'm going to personally fucking find the guy who decided it would be a good idea to mutate a well defined programming language and spread it to the public like a flu that confuses and corrupts logic and syntax.

Name: Anonymous 2012-04-21 11:50

C doesn't have operator overloading, so you can't.
You can define functions however, which you can use the () operator on, if you so wish.

Name: Anonymous 2012-04-21 12:27

You can't overload any operators in C.

Name: Anonymous 2012-04-21 13:03

>>2,3
Wrong. I can overload any other operator just fine, it's just the function call "()" operator I'm having trouble with.

Name: Anonymous 2012-04-21 14:03

>>4
Then you're not writing C. You're writing C++. C has no operator overloading whatsoever.

Name: Anonymous 2012-04-21 15:05

LOL what a fag
overloading anything in C
bitch go back to your OOP toilet scrub
nice thread would read again
check'them base 5 dubs

Name: Anonymous 2012-04-21 17:18

You uae C++ instead. Since C++ includes the entire C Standard Library you could write your code exactly as you would in C and only use C++ features when necessary (though there are some differences from C99).

Name: Anonymous 2012-04-21 17:42

>>7
This is what Sepples users really believe.

Name: Anonymous 2012-04-21 18:00

>>4
Then whatever language you're writing in sure as hell isn't C.

Name: Anonymous 2012-04-21 18:06

You guys, I think he might be writing Sepples and not C. Let's repeat this observation a few more times.

Name: Anonymous 2012-04-21 19:36

fuck u guys i switchd to asm im gonna make my own OS

Name: Anonymous 2012-04-21 19:40

>>6
u overloaded my anus~

Name: Anonymous 2012-04-21 21:44

I wrote a pineapple emulator

Name: Anonymous 2012-04-22 9:11

>>13
But what if the definition of pineapple is influenced by your emulator and the pineapple itself is actually an emulator of your emulator? We shall never know!

Name: sage 2012-04-24 6:09

sage

Name: bampu pantsu 2012-05-29 4:33

bampu pantsu

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List