Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <list>
- #include <algorithm>
- #include <iterator>
- #include <stdlib.h>
- #include <sstream>
- #include <string>
- #include <numeric>
- #include <iostream>
- using namespace std;
- template<class T>class Comparable
- {
- public:
- virtual T compareTo(T obj) = 0;
- };
- template<class T>class CTableColumn:Comparable<int>
- {
- private:
- string rowName;
- string colName;
- string content;
- public:
- CTableColumn()
- {
- rowName = "\0";
- colName = "\0";
- content = "\0";
- }
- CTableColumn(string rowName, string colName, const T content)
- {
- rowName = rowName;
- colName = colName;
- content = content;
- }
- CTableColumn(const CTableColumn& ob)
- {
- rowName = ob.rowName;
- colName = ob.colName;
- content = ob.content;
- }
- string getRowName()const { return rowName; }
- string getColName()const { return colName; }
- T getContent()const { return content; }
- void setValue(const T& content) { content = m_content; }
- void compareTo(CTableColumn toObj)
- {
- if (rowName > toObj.rowName && colName > toObj.colName && content > toObj.content) return 1;
- else if (rowName < toObj.rowName && colName < toObj.colName && content < toObj.content) return -1;
- else return 0;
- }
- bool CTableColumn :: operator < (CTableColumn& ob) const { return ((rowName < ob.rowName) && (colName < ob.colName) && (content < ob.content)); }
- bool CTableColumn :: operator == (CTableColumn& ob) const { return ((rowName == ob.rowName) && (colName == ob.colName) && (content == ob.content));
- bool CTableColumn :: operator + (CTableColumn& oRes) const
- {
- CTableColumn oRes((rowName + oRes.rowName) && (colName + oRes.colName) && (content + oRes.content));
- return oRes;
- }
- friend istream operator >> (istream is, CTableColumn ob);
- friend ostream operator << (ostream os, CTableColumn ob);
- }
- };
- template<CTableColumn, int> void CTableColumn<int> ::istream& operator >> (istream is, CTableColumn ob)
- {
- cout << "Row Name:"; is >> ob.rowName;
- cout << "Col Name:"; is >> ob.colName;
- cout << "Content:"; is >> ob.content;
- return is;
- }
- template<CTableColumn int > void CTableColumn::ostream& operator << (ostream os, CTableColumn ob)
- {
- os << ob.getRow() << " - " << ob.getCol() << " - " << ob.getContent() << endl;
- return os;
- }
- template<class T> class CTable : public CTableColumn<string>
- {
- private:
- string name;
- };
- void main()
- {
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement