reference to self ... so to speak

This is a discussion on reference to self ... so to speak within the C++ Programming forums, part of the General Programming Boards category; I guess that's why I get an error when I'm creating the class...

  1. #16
    Registered User
    Join Date
    Oct 2008
    Posts
    9
    I guess that's why I get an error when I'm creating the class

  2. #17
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Fair enough. I do silly things all the time.

  3. #18
    Registered User
    Join Date
    Oct 2008
    Posts
    9
    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

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    Could you provide more code and the exact error message? It makes it easier to help diagnose the problem.

  5. #20
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    anitiot is a good word I was reading it as Ani-tiot. Which is clearly not the intent
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,026
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #22
    Registered User
    Join Date
    Oct 2008
    Posts
    9
    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..
    Last edited by scorche; 10-02-2008 at 01:00 PM.

  8. #23
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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
    "anitiot isn't defined yet."

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,026
    Quote Originally Posted by master5001 View Post
    IBut on the C board I am allowed to call a pointer parameter (*) a reference.
    I will disagree.
    A pointer is not a reference, even if it's C.
    But of course, I'm not allowed to dictate what you are allowed to do and what you are not.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,026
    Quote Originally Posted by master5001 View Post
    ...but in C and assembler a pointer is the only way to pass by reference...
    No, you can only pass by pointer.
    Simple.

    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.
    Usually, from what I've seen or remembered, I don't think it matters that much if you pointer, address or reference.
    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.
    Last edited by Elysia; 10-02-2008 at 01:46 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #27
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    >> 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.

  13. #28
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    Quote Originally Posted by Elysia
    No, you can only pass by pointer.
    Simple.
    "Pass by reference" is a parameter passing method in the literature. It can be implemented via pointers, C++ references, etc.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #29
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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

  15. #30
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by laserlight View Post
    "Pass by reference" is a parameter passing method in the literature. It can be implemented via pointers, C++ references, etc.
    You are my official best friend of the day. Thank you laserlight.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 05:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21