Quote:
Originally Posted by Chips Ahoy
Quote:
Originally Posted by tyler_cracker
yeah lol custom C++ implementation. how you doing on incorporating the new C++11 features?
if you work with c++ and haven't read Effective C++: 55 Specific Ways to Improve Your Programs and Designs , you probably should (although one of my co-workers suggested that a better subtitle would be '55 specific reasons not to write software in c++').
With our C++ implementation it's actually really rare that I have issues with it and it adds some really nifty features that I don't know how I'll live without if I ever leave.
I'm blissfully unaware of what C++11 is.
Anyway, it turns out the example that I wrote above is over-simplified and it actually works for me - the issue seems to be with overloading virtual functions, which I wasn't doing in the example. I tried compiling this and it gave an error:
Code:
struct StructOne
{
float x;
float y;
};
struct OtherStruct
{
int x;
int y;
};
class Parent
{
public:
virtual ~Parent() {}
virtual int DoStuff( StructOne* x ) { return x->x + x->y; }
virtual int DoStuff( OtherStruct* y ) { return (int)(y->x + y->y); }
};
class Child : public Parent
{
public:
// redefine one function from parent
virtual int DoStuff( OtherStruct* y ) { return (int)(y->x - y->y); }
};
int main( void )
{
StructOne x = { 1, 2 };
Child child;
child.DoStuff( &x );
}
Quote:
'()' : incompatible types converting from 'struct StructOne*' to 'struct OtherStruct*'
see parameter #1 for Child:: DoStuff
Does that work for you, Chips?