matrixelements.h

来自「这是数据结构、算法与应用-C++语言描述的代码」· C头文件 代码 · 共 45 行

H
45
字号
// element types used by class linkedMatrix

#ifndef matrixElements_
#define matrixElements_

#include "extendedChain.h"

using namespace std;

template<class T>
struct rowElement 
{
   int col;
   T value;

   bool operator !=(const rowElement<T>& y)
      {return (value != y.value);}
   void output(ostream& out) const
      {out << "column " << col 
           << " value " << value << endl;}
};

template<class T>
ostream& operator<<(ostream& out, const rowElement<T>& x)
   {x.output(out); return out;}

template<class T>
struct headerElement
{
      int row;
      extendedChain<rowElement<T> > rowChain;

      bool operator !=(const headerElement<T>& y)
         {return (row != y.row);}
      void output(ostream& out) const
         {out << "row " << row << endl << "  " << rowChain << endl;}
};

template<class T>
ostream& operator<<(ostream& out,
                    const headerElement<T>& x)
   {x.output(out); return out;}

#endif

⌨️ 快捷键说明

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