True Kevin. I was just clarifying.
Rats, stupid comment again ! Of course that was overloading... I really should read my posts before clicking the "add post" button. :wave:
Darwen.
Printable View
True Kevin. I was just clarifying.
Rats, stupid comment again ! Of course that was overloading... I really should read my posts before clicking the "add post" button. :wave:
Darwen.
:lol: It happens to all of us! :D
I was sure someone will come to this conclusion.Quote:
Originally Posted by KevinHall
It's 3:30 AM here, so I hope I did not make any mistake...Code:struct ParamBase
{
virtual ~ParamBase();
};
struct CharParam: public ParamBase
{
char *buffer;
int size;
// whatever else needed
};
struct UCharParam: public ParamBase
{
unsigned char *buffer;
int size;
// whatever else needed
};
struct UShortParam: public ParamBase
{
unsigned short *buffer;
int size;
// whatever else needed
};
class StrategyConverter
{
public:
bool Convert(ParamBase* param1, ParamBase* param2);
};
class Char2UShortConverter
{
public:
bool Convert(ParamBase* param1, ParamBase* param2)
{
CharParam* p1 = (CharParam*)param1;
UShortParam* p2 = (UShortParam*)param2;
// perform the conversion
}
};
int main()
{
CharParam *param1 = new CharParam(...); // fill with appropriate data
UShortParam *param2 = new UShortParam(...); // fill with appropriate data
StrategyConverter *conv = new Char2UShortConverter();
conv->Convert(param1, param2);
delete param1;
delete param2;
delete conv;
return 0;
}
That way of explaining don't you see is completely non-sense ?Quote:
Originally Posted by darwen
I am not talking about word, or grammar processing but about logical reasoning instead. Sounds like a fortune teller.
you already wrote a class with static void convert functions, now may i ask if you could post the code perhaps one of the functions you mentioned if possible to show their changes anyway ? :)Quote:
Originally Posted by darwen
Oh, Jesux Christ, the terms you use remind me of teh days when C# was first invented by MS to compete with Sun's java after a famous trial I guess all of us know well, surely also with the intention that it was going to be another OOL but have you ever wondered if it is really true or still untrue in some aspects ?True OOL, so fast is your conclusion i mean...Quote:
Originally Posted by darwen
--Oh my (NO GOD)! <grabber>
Cilu,
I see what you're doing. However, you must admitt that unless there is some other compelling reason to create ParamBase and associated classes, that the heirachy and strategy pattern are overly complex to solve a problem that could otherwise be more easily solved with simple overloading. I mean, why complicate things with a class heirarchy, virtual function calls, and calls to new and delete? All this seems to add a lot of unnecessary overhead in my opinion.
- Kevin
I won't argue with that. I didn't say it's the best solution. I said it's a solution, that should be considered. And I've shown how it can be done. That's all.Quote:
Originally Posted by KevinHall
:lol: Ok! :D
So, the conclusion of the matter is that simple overloading is the most straight-forward solution for this problem if taken in isolation. However, if there exists other related problems in your application, there are other possible solutions that may make sense to help tie the different concepts together. The strategy pattern is one of these possible solutions.
- Kevin
Remember, don't use a sledge-hammer to make a square peg fit into a round hole!