I guess that's why I get an error when I'm creating the class
Printable View
I guess that's why I get an error when I'm creating the class
Fair enough. I do silly things all the time.
now I get an error here :
Code:myVector[myClass.size-1]._reference_tomyClass = & myVector[myClass.size];
I think I did it right ... but maybe I missed something
***** EDIT
I'm anitiot ...
I missed the ()
thanks everyone for your help
Could you provide more code and the exact error message? It makes it easier to help diagnose the problem.
anitiot is a good word :) I was reading it as Ani-tiot. Which is clearly not the intent
Can I recommend that you avoid using the word "reference" for pointers and vice versa?
In C++, a pointer to something is NOT a reference to something.
You can create confusion. But regardless if don't, it's just good practice to name your variables correctly.
right... 'cause they're 2 different things
except i'm pointing to a class that I'm refrencing it to. so I'm calling it a reference not because it is a c++ reference, but because in the use of it, I use it as because refrence-relation to another class, but then I didn't need to have it in the examples..
I will make a compromise with you, Elysia. I will always call a reference (&) a reference on the C++ board, and a pointer (*) a pointer on the C++ board. But on the C board I am allowed to call a pointer parameter (*) a reference.
By the way:Quote:
Originally Posted by urbandictionary
Well I do try to be respectful of other competent members. I suppose this may be an issue of newfangled teaching techniques that are floating around these days. I can agree with you to an extent, but in C and assembler a pointer is the only way to pass by reference. If anything, I would make stronger argumets for a reference to be renamed to something else. But there is no more appropriate moniker than "reference." So without introducing circular logic the point is moot. I do appreciate your concern over use of the appropriate descriptions though. It is beneficial to those who are learning. But a lot of books will also tend to say something is being passed by reference (when you would say "pointer").
If anything, I can re-negotiate the compromise to for C I will use the term "passing by address" which I think even you can conceed is accurate and unambiguous. But using such terms runs the risk of people not knowing what I mean.
No, you can only pass by pointer.
Simple.
Usually, from what I've seen or remembered, I don't think it matters that much if you pointer, address or reference.Quote:
If anything, I can re-negotiate the compromise to for C I will use the term "passing by address" which I think even you can conceed is accurate and unambiguous. But using such terms runs the risk of people not knowing what I mean.
And if they don't know, then it is a simple matter of educating them.
But I stand firm to my own beliefs that you can not pass by reference in C, only by pointer. The end.
I am grateful that you are trying to respect this, though.
>> I suppose this may be an issue of newfangled teaching techniques that are floating around these days. <<
I think this might just be Elysia's personal preference. I know I've never heard anybody else complain about referring to a pointer as referencing another object.
As long as people are aware that in C++ the term "reference" has a specific well-defined meaning beyond the normal programming term, then I don't think its wrong to use both in the proper context.
It's like the terms string or map. There is a C++ string and a C++ map, but that doesn't mean that a sequence of characters can't also be called a string and it doesn't mean you can't map one object to another with something other than a std::map.
>> No, you can only pass by pointer. Simple. <<
Not so simple. Pass-by-reference is a well defined programming term. You can't just stop using it because the word reference is used elsewhere.
"Pass by reference" is a parameter passing method in the literature. It can be implemented via pointers, C++ references, etc.Quote:
Originally Posted by Elysia
Yeah we will have to agree to disagree. Though I guess I agree with you almost asymptotically. I mean there is only a very small amount of disagreement on the issue. I can certainly say its one of those things I will have to shrug off because it doesn't matter. I just hate needing to "choose my words carefully." However look at the silver lining, I will just say what I am going to say and by doing so you are guaranteed a boost in post count ;)