Original Post
Hi, I'm currently switching my project from VC6 to Dev-C++ and in the process finding stuff thats making me question my knowledge of C++. Passing args to functions by reference is one of those things thats giving me trouble. Consider the following: It seems that VC6 is too forgiving on this one, since it lets me get away with this. Dev-C++ (MingW) on the other hand doesnt compile, telling me that 'no overloaded function blablabla...'. I always though of this as a 'unnamed' variable of type color_t being created on the stack (in main) and then passed by reference to render_stuff(), and it sort of made sense to me. I've based my Renderer class almost entirely in args passed by reference (vertices, normals, colors, etc...), but I still want the user to be able to call them 'on the fly' so to speak. Any way of getting around this or will I really have to switch to arguments passed by value? Thanks.
#define UCHAR unsigned char
struct color_t
{
color_t(UCHAR _r, UCHAR _g, UCHAR _b, UCHAR _a): r(_r), g(_g), b(_b), a(_a) {}
UCHAR r, g, b, a;
};
void render_stuff( color_t &f) // <- notice the reference
{
// render stuff
}
int main()
{
render_stuff( color_t(10, 10, 10, 255) );
return 0;
}