in my main i have
int main(){
Stock microsoft;
cin %26gt;%26gt; microsoft;
wich calls my overloding operator func;
istream%26amp; operator%26gt;%26gt;(istream%26amp; in, const Stock%26amp; aStock){
//idon't get what goes in here?
return in;
}
now how do i ask for the users input and store it in a member variable of aStock?
for example i would want the user to input put "Microsoft" and then i would like to store it in the Stock Class's member function mName... Help i don't understand??
How to overload the %26gt;%26gt; operator in C++?
first of all you class members are to be mentioned.
i dont know ur members so i am assuming my own.
let int x; and float ; be you members then,
istream %26amp; operator%26gt;%26gt;(....)
{
int a;
float b;
cin%26gt;%26gt;a%26gt;%26gt;b;
x=a;
y=b;
}
its all you need to do;
you have to take the inputs as per ur need.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment