Linked by Owen Anderson on Mon 19th Apr 2004 05:43 UTC
General Development For years the development scene has been dominated by the C family of languages, primarily C itself and its immediate successor C++. Recent years have given rise to other C-descendents, however, such as Sun's Java and Microsoft's C#.
Permalink for comment
To read all comments associated with this story, please click here.
by Anonymous on Mon 19th Apr 2004 16:47 UTC

>anytype func_any(anytype a)
>//perform an integer operation
>b=new int[4];
>return b;

From your less-than-obvious-sample it is hard to tell what you´re actually trying to show.

If the type of your argument is set at compile-time, you´re best of with a template-function, if it is not set at compile-time and you´re using the anytype as a kind of variant/multi-type kind of type, it would be better if you´re code reflected that with a isString/isInt/isBla member function (Ugly, but possible). If you´re using typeof in the sense to act differently upon the type of anytype in the sense of polymorphism, then your sample shows nothing but bad design.

What is your sample supposed to show ?

Is this code you actually write ? Samples like that actually did make it into Stroustrups "C++ Programming Language" Book. Right into the "How not to do it"-section.