By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

I've Got A problem On Referencing Functions

P: n/a
Hello all u guys out there

Ive got a problem Undrestanding in example what it means

class point
{
....
}
point &function1()
{
point sample;
return sample;
}

whats meaning of & in a function??

Tank you

Jun 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
* im*************@gmail.com:
Hello all u guys out there
"you"

Ive got a problem Undrestanding in example what it means
missing apostrophe, uppercase U, "understanding"

class point
{
...
}
missing semicolon

point &function1()
{
point sample;
return sample;
}
for a newbie this function constitutes an error

whats meaning of & in a function??


missing apostrophe, extranous question mark

the meaning of "&" depends on the context; consult your nearest C++
textbook.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jun 24 '06 #2

P: n/a
Alf P. Steinbach wrote:
* im*************@gmail.com:
Hello all u guys out there

"you"

Not all of us sit on bonfires on the 5th of November...

--
Ian Collins.
Jun 24 '06 #3

P: n/a
* Ian Collins:
Alf P. Steinbach wrote:
* im*************@gmail.com:
Hello all u guys out there


"you"

Not all of us sit on bonfires on the 5th of November...


:-)

Actually our bonfire night, in Norway, is tonight, 23/24th of June,
midsummer's night!

One bonfire got a little out of hand this year (it was probably
calculated using C instead of C++): <url:
http://www.aftenposten.no/nyheter/iriks/article1365611.ece>. The guy on
the left in the upper photo is probably the one who sat on top.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jun 24 '06 #4

P: n/a
i'm not good in english...
then accept my Apologize

in example in file below if you clean & before operator you got an
error
why it couldn't answer when we erase & ?

//phonenumber.h

#ifndef PHONENUMBER_H
#define PHONENUMBER_H

#include <iostream>
using std::ostream;
using std::istream;

#include <string>
using std::string;

class PhoneNumber
{
friend ostream &operator<<( ostream &, const PhoneNumber & );
friend istream &operator>>( istream &, PhoneNumber & );
private:
string areaCode; // 3-digit area code
string exchange; // 3-digit exchange
string line; // 4-digit line
}; // end class PhoneNumber

#endif

----------------
//PhoneNumber.cpp

#include <iomanip>
using std::setw;

#include "PhoneNumber.h"

// overloaded stream insertion operator; cannot be
// a member function if we would like to invoke it with
// cout << somePhoneNumber;
ostream &operator<<( ostream &output, const PhoneNumber &number )
{
output << "(" << number.areaCode << ") "
<< number.exchange << "-" << number.line;
return output; // enables cout << a << b << c;
} // end function operator<<

// overloaded stream extraction operator; cannot be
// a member function if we would like to invoke it with
// cin >> somePhoneNumber;
istream &operator>>( istream &input, PhoneNumber &number )
{
input.ignore(); // skip (
input >> setw( 3 ) >> number.areaCode; // input area code
input.ignore( 2 ); // skip ) and space
input >> setw( 3 ) >> number.exchange; // input exchange
input.ignore(); // skip dash (-)
input >> setw( 4 ) >> number.line; // input line
return input; // enables cin >> a >> b >> c;
} // end function operator>>

Tanx

Jun 24 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.