O'Reilly logo

C++ Primer Plus by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Listing 14.1. studentc.h

// 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;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required