-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudentc.h
40 lines (37 loc) · 1.04 KB
/
studentc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// studentc.h -- defining a Student class using containment
#ifndef STUDENTDC_H_
#define STUDENTDC_H_
#include <iostream>
#include <string>
#include <valarray>
class Student
{
private:
typedef std::valarray<double> ArrayDb;
std::string name;
ArrayDb scores;
std::ostream & arr_out(std::ostream & os) const;
public:
Student() : name("Null Student"), scores() {}
Student(const std::string & s)
: name(s), scores() {}
explicit Student(int n) : name("Nully"), scores(n) {}
Student(const std::string & s, int n)
: name(s), scores(n) {}
Student(const std::string & s, const ArrayDb & a)
: name(s), scores(a) {}
Student(const char * str, const double * pd, int n)
: name(str), scores(pd, n) {}
~Student() {}
double Average() const;
const std::string & Name() const;
double & operator[](int i);
double operator[](int i) const;
friend std::istream & operator>>(std::istream & is,
Student & stu);
friend std::istream & getline(std::istream & is,
Student & stu);
friend std::ostream & operator<<(std::ostream & os,
const Student & stu);
};
#endif