Understanding Classes

Posts 1–4 of 4 · Page 1 of 1
Understanding Classes
Finally on chapter 7 of this C++ Primer book and it's all about classes. Thought I had a decent idea of classes until it started to do this
Code:
struct Sales_data {
	//	new members: operations on Sales_data objects
	std::string isbn() const { return bookNo; }
	Sales_data& combine(const Sales_data&);
	double avg_price() const;
	//	data members are unchanged
	std::string bookNo;
	unsigned unites_sold = 0;
	double revenue= 0.0;
};
Just completely lost... And its explanation of everything that's being declared is very difficult to understand, even after re-reading...

I'm gonna try and do some googling but if anyone has some good tuts on classes that would be appreciated
Well Bucky's tutorial on youtube was extremely informational but I'm still confused on

Code:
	std::string isbn() const { return bookNo; }
	Sales_data& combine(const Sales_data&);
	double avg_price() const;
I understand the Sales_data& (it's a constructor that takes a Sales_data& parameter)
I don't understand why there's const after std::string isbn() and double avg_price()
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us