Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "string.h"
- #include <cmath>
- #include <fstream>
- using namespace std;
- class Interval {
- protected:
- double kezdopont, vegpont;
- string filename;
- public:
- //paraméter
- Interval(double kezdopont, double vegpont){
- this->kezdopont = kezdopont;
- this->vegpont = vegpont;
- print();
- }
- //konzolbol
- Interval() {
- cout << "Kerem a parametereket! (kezdopont vegpont)" <<endl;
- cin >> kezdopont >> vegpont;
- }
- //fájlból olvas be
- Interval(string filename) {
- ifstream fin(filename);
- while (fin >> kezdopont >> vegpont) {
- cout << kezdopont << vegpont << endl;
- }
- }
- void save(string filename) {
- ofstream file;
- file.open(filename);
- file << kezdopont << " " << vegpont << endl;
- file.close();
- }
- void print() {
- cout << "[ " << kezdopont << " , " << vegpont << " ]" << endl;
- }
- //visszater az intervallum hosszaval
- double length() {
- return abs(vegpont - kezdopont);
- }
- };
- class ColorInterval :Interval {
- private:
- char* color;
- public:
- ColorInterval(char *color) {
- this->color = color;
- print();
- }
- void print() {
- cout << "[ " << kezdopont << " , " << vegpont << " ]" << "(" << color << ")" << endl;
- }
- };
- int main() {
- //Interval interval(4, 50);
- //Interval();
- ColorInterval("red");
- //Interval("source.txt");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement