Hoi allen,
heb dit
Maar nu heb ik dus: cin << phone; Dat werkt. Maar normaal moet zijn cin >> phone;?? toch?
Want als ik doe: cin >> phone; krijg ik de error: Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'Phonenumber' (or there is no acceptable conversion) c:\users\savantking\documents\visual studio 2008\projects\pointer2\phonenumber\test.cpp 18 Phonenumber
Hoe kan dit?
Ik gebruik: MVS(visual studio). Is dit een bug?
THX!!
heb dit
PHP:
#ifndef PHONENUMBER_H
#define PHONENUMBER_H
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Phonenumber
{
friend ostream &operator << (ostream &, const Phonenumber &);
friend istream &operator << (istream &, Phonenumber &);
public:
string areaCode;
string exchange;
string line;
};
#endif
PHP:
#include "stdafx.h"
#include "Phonenumber.h"
#include <iomanip>
//#include <iostream>
//#include <string>
using namespace std;
ostream &operator <<(ostream &output, const Phonenumber &number)
{
output <<"("<< number.areaCode <<")"
<< number.exchange << "-" << number.line;
return output;
}
istream &operator <<(istream &input, Phonenumber &number)
{
input.ignore();
input >> setw(3)>> number.areaCode;
input.ignore(2);
input >> setw(3) >> number.exchange;
input.ignore();
input >> setw(4) >> number.line;
getchar();
return input;
}
PHP:
// Phonenumber.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include "Phonenumber.h"
using namespace std;
int main()
{
Phonenumber phone;
cout << "Enter phonenumber" << endl;
cin << phone;
cout << "The phonenumber u entered was: ";
cout << phone << endl;
getchar();
return 0;
getchar();
}
Maar nu heb ik dus: cin << phone; Dat werkt. Maar normaal moet zijn cin >> phone;?? toch?
Want als ik doe: cin >> phone; krijg ik de error: Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'Phonenumber' (or there is no acceptable conversion) c:\users\savantking\documents\visual studio 2008\projects\pointer2\phonenumber\test.cpp 18 Phonenumber
Hoe kan dit?
Ik gebruik: MVS(visual studio). Is dit een bug?
THX!!