@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4



Comments:

<0> char array[10][100] makes an array of 10 char arrays of 100 chars each
<0> Make SURE you don't try to store any string over 99 bytes in one of those or you'll get array overflow problems
<1> std::string names[10]; for (size_t i(0); i < sizeof(names)/sizeof(std::string); ++i) std::getline(std::cin, names[i]);
<0> Question myself. Will char array[10][100] = { "" }; initialize each of the 10 c-strings to an empty string or just the first one?
<0> Unfortunately, tequilla, he said he's not gotten to std::strings yet so isn't allowed ot use them. I tried to get him to use 'em myself
<1> only the first one
<2> Bloody connection
<1> wb Phr34ck
<0> wb
<1> g'night
<2> So I was saying, I want to create an array of 10 names using char *Names[10]
<2> Thanks.
<0> With your current knowledge you would have to use an initialization list
<0> Because otherwise you are not allocating memory with them that way
<2> Good night.
<2> Wet dreams.



<0> so use Names[10][100] isntead
<0> because Names[10][100] allocates the memory for you
<2> Serpardum, so it's better to use two dimension array.
<0> Not neccessarily, but in your case, yes.
<0> it's better ot use std::strings
<0> std::strings handle their own memory and you odnt' have to worry about it
<2> Serpardum, I think we'll take that next semester
<0> What cl*** is this you're taking? what's the name of it?
<2> Serpardum, can you explain for me why we p*** a char array as a pointer?
<2> Programming I.
<0> Because all arrays are p***ed as pointers almost all the time
<2> Yes, but in all the example, I see this void copy(char *s1 .... )
<0> int MyIntArray[100]; MyFunction(MyIntArray); p***ed the pointer
<2> We used to p*** arrays by names
<2> Like integer arrays
<0> you mean by value?
<0> arrays get p***ed by pointer, not by value normally
<2> Serpardum, umm I think yes but we didn't use * before
<0> void MyFunction(int MyIntArray[10]);
<0> That accepts an integer pointer.
<2> Like, when we had int a[5] and we went to p*** it to a function, we just write this: void function1(a);
<0> Which should be pointing to an array of 10 integers
<0> Right.
<0> Because a IS a pointer
<0> the name of an array is a pointer.
<0> not the whole array
<0> It is a pointer to the array
<2> Okay, I'm with you. So we have to use function1(char *s1) when p***ing a character array?
<0> or function1(char s1[])
<0> or function(char s1[10])
<2> why not just putting the name, like in the int example.
<2> So there is no difference?
<0> Beccuase here you're delcaring the function, nto the variable
<0> in the function declaration you state what is to be p***ed
<0> void function1( <what does this function accept as parms> )
<0> and you have to be specific what each parmater is
<2> Serpardum, I know that. That wasn't my question.
<0> a pointer, a value, etc..
<0> so what was your question?
<2> In integer arrays, we put just the name of the array. In character arrays we use a pointer like: void function1(char *s1). Can we use that in integer arrays?
<0> "in enterger arrays, we put just the name of the array." where? show me an example.
<0> C and C++ doesn't char what is an array of. they're treated the same. It does care if they're chars, integers or yourcl***.
<2> For example. We have this function: void function1(int a) { cout << a[2]; }, and in our program, we have this array: int a[5], and we want to call that function, we just write function1(a);
<0> Teh syntax doesn't change if it's an array of ints, chars or anythign else
<0> No, that's an error.
<0> void function1(int a) accepts a single int by value.
<2> How come?
<2> int a[] ** sorry
<0> it is not a pointer, and a[2] is illegal. it won't compoile
<0> Remember, int a[] and int* a mean the same thing
<2> Ahhh
<2> *Sighs*
<0> int* a; int a[]; int a[10]; all are int pointers
<0> the last just just speicifices that it's point to 10 ints
<0> In all cases, you p*** it an int pointer
<2> I see.
<0> int a[] is a little more speicific when you are maintaining the code.
<0> seeing void MyFuction( int a[] ); I'm going to presume that this function is receiving a pointer to an ARRAY of ints.
<2> yeah, I need more practice for pointers. We just took them we didn't have time to have some practice because the semster is over
<0> void MyFuction2( int* a ); I'm going to presume that it receives a pointer to a single int. Although in either case they can be treated the same
<0> Myself, I tend to get lazy and just use int * a; in functions



<2> Do you know in Function pointers?
<0> What about function pointers?
<0> You mean like: void MyFunction( void); MyFunction; is a function pointer?
<2> void (*F[3])(int) = {function1, function2, function3}; <-- That means that we have 3 functions from the same type?
<0> Yo uhave 3 functions, each returning a void and accepting an int as an argument
<0> void (what the functions return)
<0> (*F[3]) an array of 3 function pointers
<0> (int) accepting ints as parameters
<0> if it was:
<0> int (*F[3])(float, bool) = { function1, function2, function3 }; you describe the functions.
<2> We have three functions that returns an int, and take two parameters a float and a bool
<0> correct.
<2> Any good use of 'em?
<0> Not as much in c++ as in C, but yes.
<0> In C it's a way to do a form of polymorphism
<0> In C++ there are other/better ways
<0> But there are still situations they are used
<2> What's the difference between C and C++, other then C++ has oop ?
<0> oop
<0> Well, truthfully, you should think in OOP when you program in C++
<2> So there is no point in studing C and then moving to C++.
<0> It's usually discuraged in fact
<0> Because once you get into a function mentality it's hard to loose it
<2> OOP is schedualled for next semster
<0> Pay close attention. Almost all modern day langauges use some form of OOP nowadays
<2> Do you think I should take Java? Or finish Programming II, and then doing Java?
<2> Yeah, they told me so.
<0> Well, if you plan on getting a job as a programmer, in the modern world it's good to know java
<0> since that's wehre a lot of jobs are.
<2> I'm doing computer science.
<0> Why?
<0> What are you planning on doing with your degree?
<2> I'm thinking about web applications.
<0> Then you definately need to learn java
<0> C++ is actually used little for web applications except for server code mostly
<0> AFAIK anyway
<2> There's no escape from learning Java. It's in my major cources. But I should take it before or after Programming II?
<0> It depends on what Programming II teaches you
<2> AFAIK ?
<0> As far as I know
<2> in programming II: OOP, polimorfizim or whatever
<0> polymorphism
<2> Yeah, that
<2> What does that do?
<0> yes, learn polymorphism
<0> Okay.. polymorphism.
<0> Do you know what a cl*** is?
<2> yeah, I know OOP because I used to code PHP
<0> Lets say we create a base cl*** called Animal.
<0> From that we create 2 derived cl***es, Cat and Dog
<0> Now, we have some method/function/list/whatever that wants an animal
<0> A cat is an animal
<0> So we simply p*** Cat
<0> Teh method/function/list/whatever accepts it as an animal (it doesn't know it's a cat)
<0> it "morphed" so to speak
<0> Different languages handle it differently
<0> And it can be quite invaluable.
<3> it was dipped in the electronic toxic waste barrel and become a cat
<3> with 3 eyes
<3> and 2 tails
<3> and learned karate
<0> In C++ it remains a cat under the scenes, it never changes from being a cat, but functions/methods at work on BASE cl***es can still work on it.
<0> AND, those functions can even ask if it's a cat, and if it is make it meow
<0> that utilizes in C++ what is called Run Time Type (something). RTTI
<0> I keep forgetting what hte I stands for
<0> Interface?
<0> msdn tells me: Run-Time Type Information
<4> Darwinia demo is available on steam!
<5> [11:29:03] <4> Darwinia demo is available on steam! <--- what's that?
<4> I just finished it, it's very nice
<4> it's by the people that did that hacking game ages ago
<4> the graphics are very primative (on purpose), and the gameplay is quite simplistic, but it's a great game
<4> http://www.darwinia.co.uk/


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #c++
or
Go to some related logs:

applaying for job
#allnitecafe
#chat-world
#india
#allnitecafe
what does dnfd mean?
#linux
#chat-world
#india
#allnitecafe



Home  |  disclaimer  |  contact  |  submit quotes