Hello !
I'm learning C++ by myself and I found very different ways to use constructors.
Which is the best practice?
Example 1 .h :
Code:
Product(int barCode, string const &title,
string const &author,string const &publisher,
int price );
or
Code:
Product(int , string , string , string , int );
.cpp
Code:
Product::Product(int barCode, string const &title,
string const &author, string const &publisher,
int price)
: barCode_(barCode), title_(title), author_(author),
publisher_(publisher), price_(price){}
or
Code:
Product::Product(int barCode, string const &title,
string const &author, string const &publisher,
int price)
{
barCode_ = barCode;
title_ = title;
author_ = author;
publisher_ = publisher;
price_ = price;
}