"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:47***********************@news.sunsite.dk...
colin wrote:
>I prefer c# these days,
it frees up so much time otherwise spent with memory management.
There are also ways of making that easier in C++.
im interested in the sort of thing you refer to ?
for example, I had a decision tree I wrote in c++ wich it generated from
some input data,
there was quite a bit of recusrion or loops wich had to be handled by
recognising
repeating branches and instead of going onto infinity just looping the
branch back to some equivalent point.
this meant often an entire branch would be deleted but at the time of
deletion
some of the elements in the branch may be still used elsewhere,
although elements might be used by things in the same branch wich was about
to be deleted.
with c# this is taken care of, you just simply unreference it and it
eventually deletes anything that
isnt referenced from some static point.
I had to write the code to do the same thing with my tree.
>
>If you going to do c# I would start with c#,
moving from c++ to c# isnt that easy,
as theres considerable diferences wich make it harder if your well used
to c++
such as sprintf type format is totaly diferent and theres no macros or
multiple inheritence etc.
I don't think it will take a C++ programmer many minutes to convert
from sprintf format to String.Format and note the lack of macros
and multiple inheritance. And if he forget then the compiler will'
remind him.
I remember it took me a long time to find the right page wich told me how to
print out
a simple hex dump with 2 hex digits for each byte,
I found 100s of pages wich told me how to print out the basic stuff with
String.Format but stoped short of saying how to print out exactly 2 digits.
most other things I seemed to find fairly easy.
ok I know its not dificult, its easy when you know how, but its just new.
I made the mistake of thinking it was easy transition,
instead of treating it as a new language and burying my head in a few books
for a few days.
its not a question of just noting they dont exist,
but what I meant was if your realy used to using a macro
for certain things it can be hard to code the the equivalent of the macro
template functions can be used but I find they are limited ...
for example I have several structs wich have some of the same elements and I
want to
have a function wich does the same operation on those elements for diferent
structs...
in a template function I cant access any members of a <typeunless I put a
constraint,
but then I am limited to only alowing one class, unless I am mistaken or
there is a way round this?
unfortunatly I dont have the option to add an interface to the structs
definition.
a macro would easily take care of this.
again the same for multiple inheritence, sometimes its just difuclt to
figure out how to do the equivalent.
although I think macros can be very badly misused, and multiple inheritence
could realy suck sometimes.
I think it is worse the other way around. The things that is taken
care of the runtime in .NET and that you have to do yourself in C++.
And they do not give a compiler error. Instead they give various
runtime errors that are often very hard to locate the original cause
for.
yep transition the other way is probably dificult too,
I still need C/C++ for my microcontrollers though,
its like switching to a diferent world.
and ofc its still usefull to know basic c++ if you want to do some unsafe
stuff in c#...
Colin =^.^=