⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gradebook.cpp

📁 C++大学简明教程,解压就行没有密码。希望对大家有用
💻 CPP
字号:
// Tutorial 21: GradeBook.cpp
// GradeBook member function templates definitions.
#include <iostream> // required to perform C++ stream I/O
#include <iomanip> // required for parameterized stream manipulation

#include "GradeBook.h" // include GradeBook class definition

using namespace std; // for accessing C++ Standard Library members

// one-argument constructor
template< class T >
GradeBook< T >::GradeBook( int size )
{

} // end GradeBook one-argument template constructor

// return the class size
template< class T >
int GradeBook< T >::getClassSize()
{
   return classSize;
} // end function template getClassSize 

// set the class size
template< class T >
void GradeBook< T >::setClassSize( int value )
{
   classSize = value;
} // end function template setClassSize

// return the grade at a specific index
template< class T >
T GradeBook< T >::getGrade( int index )
{
   return grades[ index ];
} // end function template getGrade

// set specified element of grades array to specified value
template< class T >
void GradeBook< T >::setGrade( T value, int index )
{
   grades[ index ] = value;
} // end function template setGrade

// display each element in the grades array
template< class T >
void GradeBook< T >::displayGrades()
{
   cout << "Student #    Grade" << endl;

   // output each student's grade
   for ( int student = 0; student < classSize; student++ )
   {
      cout << setw( 5 ) << student + 1 << setw( 13 )
           << grades[ student ] << endl;
   } // end for

} // end function template displayGrades

/**************************************************************************
 * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 * Pearson Education, Inc. All Rights Reserved.                           *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 **************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -