Hi!
I'm learning C++ and have just read about Pointers and References a bit. Now I'm not absolutely sure, that I've understood it correctly.
I asume, that (taking an example from the real world) "nepomuk" would be a reference to me, and I could have further references like "other_name " or so, that also refer to me. And of course, if you would annoy "other_name ", it would also affect "nepomuk".
[code=cpp]person nepomuk = new person(...);
person & other_name = nepomuk;
other_name.anno y();
=> nepomuk.isAnnoy ed() == true[/code]At the same time, my coordinates (say 5.2660078828054 98, -31.9921875) would be a pointer to my position? So, if you send a letter to these coordinates, I will get it. (By the way, those coordinates are somewhere in the Atlantic Ocean between Africa and South America and NOT my actual position.)
[code=cpp]person nepomuk = new person(...);
person * coordinates;
coordinates = &nepomuk;
sendLetterTo(co ordinates);
=> nepomuk.recieve sLetter() == true[/code]Is that correct?
Greetings,
Nepomuk
Edit: Acording to the "Full list of Code Tag Supported Languages", that code should be formatted. I used code=cpp. However, it says "code (text)" instead and isn't formatted at all. Has the system been changed?
Here a few other tests:[code=java]public class Test {
public static void main(String[] args)
{
System.out.prin tln("This is Java");
}
}[/code][code=html]<html>
<head>
<title>HTML</title>
</head>
<body>
<h1>This is HTML</h1>
</body>
</html>[/code][code=c]#include <iostream.h>
int main(){
printf("This should be C");
}[/code]This used to work. How weird...
I'm learning C++ and have just read about Pointers and References a bit. Now I'm not absolutely sure, that I've understood it correctly.
I asume, that (taking an example from the real world) "nepomuk" would be a reference to me, and I could have further references like "other_name " or so, that also refer to me. And of course, if you would annoy "other_name ", it would also affect "nepomuk".
[code=cpp]person nepomuk = new person(...);
person & other_name = nepomuk;
other_name.anno y();
=> nepomuk.isAnnoy ed() == true[/code]At the same time, my coordinates (say 5.2660078828054 98, -31.9921875) would be a pointer to my position? So, if you send a letter to these coordinates, I will get it. (By the way, those coordinates are somewhere in the Atlantic Ocean between Africa and South America and NOT my actual position.)
[code=cpp]person nepomuk = new person(...);
person * coordinates;
coordinates = &nepomuk;
sendLetterTo(co ordinates);
=> nepomuk.recieve sLetter() == true[/code]Is that correct?
Greetings,
Nepomuk
Edit: Acording to the "Full list of Code Tag Supported Languages", that code should be formatted. I used code=cpp. However, it says "code (text)" instead and isn't formatted at all. Has the system been changed?
Here a few other tests:[code=java]public class Test {
public static void main(String[] args)
{
System.out.prin tln("This is Java");
}
}[/code][code=html]<html>
<head>
<title>HTML</title>
</head>
<body>
<h1>This is HTML</h1>
</body>
</html>[/code][code=c]#include <iostream.h>
int main(){
printf("This should be C");
}[/code]This used to work. How weird...
Comment