Thread: can someone explain to me what Org is in this code dealing with operator functions

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    14

    can someone explain to me what Org is in this code dealing with operator functions

    Code:
    ostream &
    Code:
    operator<<(ostream& output, Bank_Acct & Org)
    Code:
    {
          output<<endl<<"Name "<<Org.name;
          output<<endl<<"The balance is "<<Org.balance<<endl;
    returnoutput;
    }
    I'm learning about operator overloading and I'm confused where Org came from

    I'm guessing it just a placeholder name like when you create functions like

    Code:
    void Add(int &a, int &b){
        a+=1;
        b+=1;
    }
    and when you call the function

    in main

    like this

    Code:
    int main(){
    
             int s=4;
             int g=5;
             Add(s,b);
    
    
    }
    so the variables don't nessarily have the same name.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,794
    Yes, it is just a parameter name.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    14
    and Org is just the actual class object that is being passed through as a reference?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,794
    Quote Originally Posted by c++noob145
    and Org is just the actual class object that is being passed through as a reference?
    No, it is the parameter (also known as the formal parameter or formal argument), which is of type reference to Bank_Acct. This is the same as if the operator<< were say, a function named "foo". It so happens that this function has a more... interesting name.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please explain this functions declaration to me
    By Swerve in forum C++ Programming
    Replies: 7
    Last Post: 04-21-2008, 06:04 PM
  2. Problem while dealing with file handling functions
    By RoshanGautam in forum C Programming
    Replies: 3
    Last Post: 02-22-2006, 01:42 AM
  3. Arrays, and Functions dealing with them
    By Argentum in forum C++ Programming
    Replies: 6
    Last Post: 12-05-2005, 07:25 PM
  4. Overloaded Functions...Can someone explain it to me
    By -dcx- in forum C++ Programming
    Replies: 6
    Last Post: 11-19-2002, 09:26 AM
  5. Dealing with functions and reading char
    By hermit in forum C++ Programming
    Replies: 11
    Last Post: 06-12-2002, 06:07 AM