#include<iostream>
using namespace std;
int main()
{
istream A;
int a;
A>>a;
}
here i am making object of istream class, to take input. but the compiler shows error which I can't understand. Please help me with it...
#include<iostream>
using namespace std;
class Car
{
private:
string name;
string model;
int engine;
public:
friend istream& operator>>(istream&, Car&);
friend ostream& operator<<(ostream&, Car);
};istream& operator>>(istream &d, Car &e) {
d>>e.name>>e.model>>e.engine;
return d;
}ostream& operator<<(ostream &d, Car e)
{
d<<e.name<<" "<<e.model<<" "<<e.engine;
return d;
}
int main()
{
Car a;
Car b;
cout<<"enter car credentials";
cin>>a>>b;
cout<<a<<b;
}
i want to overload the extraction and insertion operators >> << by myself, in my class. so here I have to make references of istream and ostream. so I want to know why I can't make objects of them. I'll add the complete code.. –