I'm trying to write a class that reads a file or input but I'm having trouble figuring out the constructors. I want a constructor that reads a file name and one that reads from an istream.
I'm not sure if that makes sense so I'll add my code if it helps.
main.cc:
#include "Doc.h"
#include <cassert>
#include <stream>
#include <iostream>
#include <string>
using namespace std;
int main() {
// Read from file
Doc document("romeo.txt");
// Read from stream
ofstream("data") << "\r \r \n\nPeter \n Ray\r \n Egon \n \n\r\n";
Doc d("data");
return 0;
}
Doc.h:
#ifndef DOCUMENT_H
#define DOCUMENT_H
#include <iostream>
#include <string>
class Doc {
public:
Doc(); // Default Constructor
Doc(const Doc &); // Copy Constructor
~Doc(); // Destructor
Doc& operator=(const Doc &); // Assignment Constructor
// File path constructor
Doc(std::string file_path); // Doc(path)
// Istream constructor
Doc(std::istream& input); // Doc(istream)
}