Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have come across a function definition starting as:

int operator*(vector &y)
{
body
}

After putting * just after operator and before opening brace of argument what this function means?
Posted

I's the definition of an overloaded operator[^]
 
Share this answer
 
This is a feature provided by the C++ called operator overloading . Using this you can change the meaning of operator if it is used in context of your class object.

Have a look at the following code.

Class YourClass
{

public :

int operator*(vector &y)
{
body

}

};

main ()
{
   vector v;
   YourClass y;
   y*v;    ///Here operator* function will be called and v will be passed as a parameter

}
 
Share this answer
 
Comments
Stefan_Lang 25-Jul-11 5:24am    
Correct, but judging by the signature of the operator function, most likely YourClass==vector ;)
PrafullaVedante 25-Jul-11 11:46am    
he he he thats right ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900