Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //File.h
- #ifndef FILE_H
- #define FILE_H
- #include "./String.h"
- class File
- {
- public:
- String filePath;
- File();
- void open(String filePath);
- void close();
- void save();
- void saveAs();
- void help();
- void exit();
- ~File();
- protected:
- private:
- };
- //String.h
- #endif // FILE_H
- #ifndef STRING_H
- #define STRING_H
- class String
- {
- public:
- String();
- String(const char *s);
- String operator+(String other);
- String& operator=(const String& other);
- bool operator==(String other);
- const char* getStr()const;
- ~String();
- private:
- char* str;
- };
- #endif // STRING_H
- //File.cpp
- #include "../include/File.h"
- #include <fstream>
- #include "../include/String.h"
- File::File()
- {
- }
- public:
- String filePath;
- open(String filePath);
- String str;
- String filePath;
- ofstream table(filePath);
- String line;
- while (std::getline(filePath, line))
- {
- std::istringstream iss(line);
- std:: cout << iss << std::endl;
- // if (!(iss >> a >> b)) { break; } // error
- // process pair (a,b)
- }
- void File::close();
- void File::save();
- void File::saveAs();
- void File:: help();
- void File:: exit();
- File::~File()
- {
- //dtor
- }
- //String.cpp
- #include "String.h"
- String::String()
- {}
- String::String(const char *s)
- {
- str = new char[strlen(s)+1];
- strcpy(str, s);
- }
- String String::operator+(String other)
- {
- String result;
- result.str = new char[strlen(str)+strlen(other.str)+1];
- strcpy(result.str, str);
- strcat(result.str, other.str);
- return result;
- }
- String& String::operator=(const String& other)
- {
- delete[] str;
- str = new char(strlen(other.str)+1);
- strcpy(str, other.str);
- return *this;
- }
- bool String::operator==(String other)
- {
- if(strcmp(str, other.str) == 0)
- return true;
- else
- return false;
- }
- const char* String::getStr()const
- {
- return str;
- }
- String::~String()
- {
- delete[] str;
- }
- std::ostream& operator<<(std::ostream& os, String other)
- {
- os << other.getStr();
- return os;
- }
- //main
- #include <iostream>
- #include "./include/String.h"
- #include "./include/File.h"
- #include <cstring>
- using namespace std;
- int main()
- {
- //File Table;
- int test = 123456789;
- // std::cin >> Table.filePath;
- std::cout << test;
- //Table.open(Table.filePath);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment