| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9
Comments:
<0> Anything that asks for a char* should also expect a size, naturally. <1> ok <0> A static array would work just as well there, of course. <0> char myBuffer[100] = {0}; <0> You just don't get the niftiness of std::vector. <1> the content of the vector are stored in contiguous manner ? <0> slimD: Yes <1> hum, that's good then :) <0> DoIt: This instructor of yours... I don't know. <0> slimD: Keep in mind that std::string has no such guarantee <1> but when you try to add some kind of data to the vector and there is no place after it ? <0> slimD: You have to expand the vector. <1> the vector will copy all the content to another place ? <0> Yes. <1> waaw <1> this will slow hard the application
<0> That's why you should usually pre-allocate vectors to some sane size. <0> Like I did above, to 100. <1> yes <1> ok, thanks a lot <1> back to work <2> Solamente, i defined an object of fstream ifile, opened with ios::in mode. after reading up to the end, and when i called tellg(), it returned -1 <0> Did your instructor cover operators << and >> at all? <2> nope :P <0> You instructor is an idiot. <0> http://www.parashift.com/c++-faq-lite/input-output.html <0> Read that. <2> he told that are called insertion and extraction operators <0> That's a far better intro to C++ I/O <2> :D <0> At least he got that right. <2> okay, thanks Solamente. <2> what this line means? std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); <2> what cin is ignoring? <0> It ignores (skips over) every character in the input stream until it encounters '\n' <0> Or until it reads the number of characters in the first parameter. <0> Which is such a large number, it's not likely to happen. <2> oh like, while((ch=getchar())!='\n'); ??? <0> Pretty much <2> hmm.. :)) <2> but, if i say cin.clear(), it clear the whole buffer, right? <0> Not necessarily. .clear() clears the state, not the contents. <2> is there anyother easy way to clear the inputstream? i mean, if a '\n' is left in the buffer. <2> am not saying that the aboveone is tough... okay can i say like cin.ignore(100,'\n') <2> ?? <2> stupid me. seems i can.. <2> as you explained it clearly... dont mind.. :) <0> The reason for std::numeric_limits<std::streamsize>::max() is that it's the maximum number of characters the stream can hold. <0> std::streamsize is the type of the variable that holds the stream size, and std::numeric_limits<T>::max() tells you the maximum numeric value that type T can hold. <2> cool... now its clear... so sweeet <2> can i apply this to any type of object? <0> Apply what? <2> i mean, int, float, double etc <0> Yes <2> to get the max size <2> okay <2> onr doubt, so in C++, is there #defines like INT_MAX or is it using the above said method? <0> That's there, but there's really no reason to use it. <0> The numeric_limits code will optimize down to the exact same thing in the compiled code. <2> compatibility with C. :)) <0> If you're using C++ streams, that's out the window anyway. <2> yeah <0> But for this particular case, you really don't want to use INT_MAX. <0> Because you don't know what the type of std::streamsize is. Nor do you care. <0> You let the compiler figure that out for you. <2> ofcourse <0> Hence, the beauty of template meta-programming (which is what this is). <2> i really need to get in to STL. <2> though, that stupid wont teach. <3> so get a book <0> A semantic note... the STL is a subset of the standard library. But a very interesting one. <2> i thought STL == Standard library? <0> STL covers containers and algorithms, whereas the standard C++ library includes streams, strings, and a few other things. <3> Standard Template Library <2> is there anything more in STL ? <3> -> template <- <2> i read, standard C++ library ==STL
<0> Streams and strings are templates, too. That's not the whole answer, Tamama. <4> the STL is an ugly template based library with weird method names like push_back() for vectors <0> DoIt: No. STL is a subset. <2> okay... <3> mr^man: heh <4> and bind_1st <3> Solamente: No it is not, but it should give a good indication that there is something else :) <0> No, it's just confusing. <4> and for_each which promotes non-locality <5> ...huh? <0> rdragon: Don't feed the troll. <5> /nod <0> He doesn't know what he's talking about. <4> troll: anyone who doesn't agree with the mainstream opinion in a channel <4> sheep: everyone who does <0> DoIt: You'd be better served by the book "Accelerated C++" <6> so everyone's a troll or a sheep? <0> And you might manage to still pick up some tidbits from this instructor of yours. <2> Solamente, here that book is not available. i tried to get <6> that seems a bit, uh, harsh <0> Where's "here"? <2> in asian continent <0> And does Amazon ship there? <4> pretty much! <3> ask the store to order it for you <4> although it's pretty mainstream to agree that for_each is mostly useless, and mem_fun and such are absurd <4> however BOOST_FOREACH solves some of this <2> Tamama, indian edition is not available. that means, i need to pay the money in Dollars... that will be some thing like 3times the cost of the books which are avilable in india <2> i can get C++ programming language book for less than 7$(indian money) here. but i think, there it will be pretty more than that <0> Well, I recommend that book because it's the best C++ tutorial I've ever seen. <0> I wish it had been around when I was learning. <2> ofcourse, the quality of paper, printing and all will be not as good as western edition <7> same here <7> I had ****e books <3> DoIt: anyway the issue you have is not that you can not get the book, but that you made the decision not to buy it <0> I learned from the Stroustrup book. While an excellent reference, it's a lousy tutorial. <3> and i dont say that is bad, mind you :) <7> i agree <2> Tamama, nope.. i asked them to try to get it.. <3> Solamente: definately so lol <7> I learned from a ****e C book telling me its C+++ <2> same like my professor, teaching C in C++and telling, that is what C++ is .. :D <8> hello, i have a question. <9> wtwtwt: Just ask. <8> i am currently learning c++, but i can't figure out which are the objects <0> Well... <0> In C++ parlance, an object is a named region of memory. <2> instance of any cl*** is an object. :) <0> But you're probably expecting the OO answer. <2> i guess, that might be the OO answer <0> There's also the issue that in C++, you can use objects without relying on the OO concepts of inheritance and polymorphism. <0> STL does this, for example, intentionally avoiding cl***ic OO design. <0> Now that I've confused you, what exactly *are* you asking? <2> hahahahaha <8> wait, i had something to do <8> :) <8> i'm reading the chapter about cl***es <0> *The* chapter? <0> Of what book? <8> and in one part when it explains about the public and private part of a cl*** <6> *the* book, surely <8> third edition c++, bjarne str. <0> Okay. <8> it says that in that way only member functions can dirrectly manipulate objects <8> so at that point i thaught that the private members are the objects <8> but now, it says about static member <8> and it says <0> wtwtw: A more accurate phrasing would have been "only member functions can directly manipulate the state of the object" <0> That's what he intended, I'm sure. <0> The data members of an object represent its state. <8> that a function that needs access to members of a cll***, yet doesn't need to be invoked for a particular object is called a static member function
Return to
#c++ or Go to some related
logs:
#mirc cum se da flood din putty ghostscript pdf2pdf 12What can stop the Duke of Earl ?
#windows #MissKitten Type 'deb' is not known #linux aidan undernet #linuxhelp
|
|