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

What does the ":" mean in the following statement?

P: 2
class FloatingLeg
{
public:
FloatingLeg(map<double, double> floatLegRate, double floatLegBasis, int payFrequency)
:floatLegRate_(floatLegRate), floatLegBasis_(floatLegBasis), payFrequency_(payFrequency){}

....}
Dec 17 '10 #1
Share this Question
Share on Google+
2 Replies


100+
P: 207
Jennifer,

What you are looking at there is an initialization list.

The class has member variables called

floatLegReate_, floatLegBasis_ , and payFrequency_

What you are doing is initializing these member variables to the arguments sent into the constructor. This way of constructing your class is more efficient than doing this.

Expand|Select|Wrap|Line Numbers
  1. class FloatingLeg
  2. {
  3. public:
  4. FloatingLeg(map<double, double> floatLegRate, double floatLegBasis, int payFrequency)
  5. {
  6. floatLegRate_ = floatLegRate;
  7. floatLegBasis_ = floatLegBasis;
  8. payFrequency_ = payFrequency;
  9. }
  10. }; 
  11.  
  12.  
  13.  
  14.  
Dec 18 '10 #2

P: 2
Understood. Thank you very much.
Dec 18 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.