April 27th, 2003, 12:05 PM
arrays and string common libaries (newbie question)
when studying my first C++ book i wonder why the hell c++ has limitations to arrays. why it can't be like in any other language that u just make an array grow by pushing values into it...
same for strings, other languages provide very efficient arithmetics to handle them...
so i wondered if someone already made a very common libary that overrides the standard c++ functionality in order to provide these - "essentials". otherwise i really first would need to do them on my own...
i am using Bloodshed Dev-C++ but shouldn't make a real diffrence...
sorry if this has been asked a thousand times already, i was not able to find it :(
April 27th, 2003, 12:14 PM
Try looking up references to the vector class, which is the kind of dynamically sized array I think you're looking for. Try here:
Also, there is a string class in C++, that isn't in C, which is *much* better than using an array of chars. There's a good guide which has exercises too here:
Confused me for a while too, especially the vector notation, but stick with it, cos it's very useful!
Hope this helps :-)
Practise Random Kindness
April 27th, 2003, 12:40 PM
well the first link is somewhat - err - "wired" because this is somekind of half half thingy but anyway i gonna have a closer look, the second link seems really helpfull thanx.
but hm, this vector thing seems to b a common standard right so possibly my compiler knows it already?
i was looking for an array object that is like hmm -
able to b multidimensional.
and having the standard push shift pop unshift reverse concat... and the like functionality (like java, php, actionscript...) ...
is there perhaps another tutorial on this vector stuff where the rest of these r going to b mentioned or does the vector class just have these few commands mentioned on that site?
April 27th, 2003, 05:47 PM
Re: arrays and string common libaries (newbie question)
So that we can write overflow exploits of course ;)
Two things have come out of Berkeley, Unix and LSD.
It is uncertain which caused the other.
April 27th, 2003, 06:15 PM
Forgot to mention that you want to
as well. There are lots of methods that can be used in the vector class. Does Dev-C++ do drop-down lists of member attributes and methods? If it does, you could declare a vector object and then use that to see what's possible. Most of the names are pretty obvious, and you can at least search for the names of those that aren't as straightforward.
As, for a 2D array, you might be able to declare it of type:
which would be a 2D dynamically sized array of ints. Can anybody confirm this by the way, as I've only used them a couple of times... Might be a total load of rubbish :-)
Any time you see a class type with <> next to it, it's a 'template' which take a type as a parameter. Googling "c++ templates" should throw up lots of useful sites. I posted a question here on this topic myself recently - "Using static modifier with templates", and it contains a small class that uses templates (though part of the syntax was initially wrong, hence the post! :-) ).
Most c++ books will tell you more about them I should think, but as always it's just a case of knowing what terms to look out for...
Practise Random Kindness
April 27th, 2003, 09:24 PM
so that u don't need to care anymore.
or #include <vector.h> sure //err, btw. what the hell is the diffrence? something related to c's history right?
damn, i knew it, i need a reference!
yes, that obviously is a beginners problem :)
allright, so i think i first gonna get myself another book also describing that template stuff...
Thanx alot majelbstoat