The Student
Class Example
At this point you need to provide the Student
class declaration. It should, of course, include constructors and at least a few functions to provide an interface for the Student
class. Listing 14.1 does this, defining all the constructors inline. It also supplies some friends for input and output.
// studentc.h -- defining a Student class using containment#ifndef STUDENTC_H_#define STUDENTC_H_#include <iostream>#include <string>#include <valarray>class Student{private: typedef std::valarray<double> ArrayDb; std::string name; // contained object ArrayDb scores; // contained object // private method for scores output std::ostream & arr_out(std::ostream & os) const;
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.