Dalto posted on Aug 3 2004 at 03:34 PM said:
Azure posted on Aug 3 2004 at 10:24 PM said:
Here's how the author explained it to me in an email:
Randy Davis via Email said:
int nValue;
declares an integer. The following:
int* pValue;
declares a pointer to an integer. As the declaration states "pValue" is of type "int*", i.e., pointer to an integer.
The value "*pValue" is the integer pointed at by "pValue". As in the following:
int nValue;
int* pValue = &nValue;
nValue = 1; // these two lines are semantically equivalent
*pValue = 1;
Does it make more sense now?
Also, it's pretty cool that he(or someone he appointed) took the time to reply. I am sure he gets a lot of email from people on his book.
Yeah, I think I understand it now. *pValue is an int because you make it "=" to an int, or something like that.
Anyways, more concepts (
):
Note: Due to the fact that there is a limit on how many pictures can be posted in one post (I tried to post 18 :lol
, I was forced to cut and paste related pics into one big picture. You should still be differentiate the different pictures that make up the one big picture).
1.
(First pic is a pic of the entire code, the second pic is a pic of the constructor in that code)
Okay, what I don't understand is, why the heck do we need contructors? In the second pic, the constructor is Student() {blah}, right? Why can't you just get rid of the constructor and initialize those two variables to 0 in the declaration? With every example the book gave of constructors (Even the more complex ones), I always thought, why not just initialize them to the value that the constructor gives them in the declaration, allowing you to forget the whole constructor thing altogether?
2.
(First pic is the code, second pic is the next page showing the 1234 error)
Okay, I don't understand this one. Why does the 1234 thing happen? And then there's supposedly a fix to this code:
(Second pic is the continuation of the code from the first pic)
Okay, so, is this really a fix? Because it appears that now the user is forced to have the user ssid equal "1234," because of the previous error. Would it still work if the ssid was another number? Here's the output from the code:
3.
(First pic is the intro before the code segment. I thought it might help if I included it. The second pic shows what I'm having trouble with, the third pic shows the rest of the code, including the part that I'm having trouble with)
Okay, with this one, what I don't understand is the "&." What's up with the function argument, "Student& refs?" I've never seen this kind of syntax. What does Student& mean? I've heard of &Student, but not Student&. Here's another pic with the "&," but this one uses it multiple times:
(Again, the first pic is the intro before the code segement, the second and third pics show what I'm having trouble with)
The "&" is here again. It's everywhere in this one. So, what's the deal with this notation?
4.
(First pic is the first part of the code, the second pic is the second part)
Okay, I think I get this but I just want to make sure. The reason why the null is placed at element 39 is because name[40] doesn't exist, right? If this is wrong, could you tell me why it's placed at 39?
5.
Okay, this one about linked lists kind of confuses me. So, in that code snippet, pL first points to the beginning of the list, right? But I don't understand how it points to the next entry in that one line of code. I don't understand how pL = pL->pNext means point to the next entry. Why isn't it pL = pNext?
(I read about the -> already, and I understood how it worked for instances and their datamembers, like s->gpa, would refer to the gpa in the instance of the class Student, s.)
6.
(In the first pic, look at the paragraphg that beings with "For example," specifically the last sentence in that paragraph. In the second pic, look at the top parapragh, specifically the sentence that begins with "You could make.")
Okay, I don't understand what's up with this or where it originated from, but what's up with the idea that classes can't rely on other things (I think that's what the rule is)? Could someone first please tell me the exact rule? So, would you get a compile error if you try to compile a class that relies on something else? If not, why can't you just ignore it?
Thanks for actually taking the time to read my long, and probably irritating (I apologize for that) posts. I'm trying my best to figure these out on my own, but sometimes I just need your help sometimes
BTW, when could I call myself a C++ Programmer or when could I say that I know C++? When I finish a beginner book? When I finish an advanced book?
One reason that I'm really motivated to learn C++ is because my brother (Who is fat, lazy, and stupid, and older than me. I hate him so much :angry: (Not just because he's fat, lazy, and stupid, but because of the things he does in regard to him being those 3)) says that I won't be able to lean C++. I don't know why he would say such a thing, considering I'm A LOT smarter than him, he still gets grades below B's, while I get straight A's, he also has "stupid" classes, I have the more advanced classes, and I even have the same level math as him and I got a better grade in it...I'm guessing he said that because
he thinks it's really hard.
BTW(2), what would you consider is harder to learn, C++ (and other programming languages) or Photoshop? Which one is more of an accomplishment?