Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TIME_H
- #define TIME_H
- /*----------------------------------------------------------------------------*/
- #include <ostream>, <sstream>, <string>, <vector>, <array>, <iostream>, <iomanip>, <fstream>, <cassert>, <math.h>
- //I cc #include "något.h"
- /*----------------------------------------------------------------------------*/
- //Bra nyckelord
- virtual, public, private, protected, override, const, *, std::, explicit, setfill("-"), setprecistion(2), fixed, setw(4);
- //Ex
- class Capacitor : public Component
- /*----------------------------------------------------------------------------*/
- Sorted_List(std::initializer_list<int> li);
- std::string to_string() const;
- operator std::string() const;
- Time operator+(int more_sec);
- Time operator-(int rhs);
- Time operator++(int);
- Time operator--(int);
- Time& operator++();
- Time& operator--();
- bool operator==(Time const &rhs) const;
- bool operator<(Time const &rhs) const;
- bool operator>(Time const &rhs) const;
- bool operator!=(Time const &rhs) const;
- bool operator<=(Time const &rhs) const;
- bool operator>=(Time const &rhs) const;
- Sorted_List& operator=(Sorted_List const & rhs); //Kopiering
- Sorted_List& operator=(Sorted_List && rhs); //Flytt
- /*----------------------------------------------------------------------------*/
- //Iterator klassen ska ligga i klassen för iteratorn
- Iterator begin() const;
- Iterator end() const;
- Iterator operator++(int);
- Iterator operator--(int);
- Iterator& operator++();
- Iterator& operator--();
- int operator*();
- bool operator!=(Iterator const &rhs) const;
- //osv beroende på vilka man behöver
- /*----------------------------------------------------------------------------*/
- //Ligger utanför men behöver getters
- std::ostream& operator<<(std::ostream &lhs, Time const &rhs);
- std::istream& operator>>(std::istream &lhs, Time &rhs);
- /*----------------------------------------------------------------------------*/
- throw (std::domain_error){ "Month " + std::to_string(month) + " doesn't exist!" };
- /*----------------------------------------------------------------------------*/
- static constexpr const std::array<int, 13> days{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //days.at(index)
- /*----------------------------------------------------------------------------*/
- //Skriv ut ett datum då funktionen är friend med ostream
- friend std::ostream& operator<<(std::ostream& os, Date rhs);
- std::ostream& operator<<(std::ostream& lhs, Date rhs)
- {
- lhs << std::setfill('0')
- << std::setw(4) << rhs.m_year << "-"
- << std::setw(2) << rhs.m_month << "-"
- << std::setw(2) << rhs.m_day
- << std::setfill(' ');
- return lhs;
- }
- /*----------------------------------------------------------------------------*/
- //Kompilatorn ska förbjudas att automatiskt konvertera enskilda heltal till en färg?
- explicit Color(int rgb);
- /*----------------------------------------------------------------------------*/
- cin.ignore(1000."\n")
- /*----------------------------------------------------------------------------*/
- //Ex for infil
- std::ifstream ifs{ "STUDENTS.TXT" };
- if (!ifs) {
- std::cerr << "Couldn't open input file\n";
- return 1;
- }
- else
- {
- std::string line;
- while (std::getline(ifs, line)) //Kan även göras med cin
- {
- std::stringstream sst{ line };
- std::cout << sst.str() << "\n";
- }
- }
- ifs.close();
- /*----------------------------------------------------------------------------*/
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement