I'd like to assign std::string *ptr via std::string::operator >> in c++.
I have a class below.
class A{
public:
    A(){
        ptr = new std::string();
    }
    A(std::string& file){
        ptr = new std::string();
        std::ifstream ifs(file);
        std::stringstream ss;
        ss << ifs.rdbuf();
        *ptr=ss.str();
        ifs.close();
    }
    ~A(){
        delete ptr;
    }
    void output(std::ostream& stream) const{
        stream << *ptr;
    }
    void input(std::istream& stream) const{
        stream >> *ptr;
    }
private:
    std::string *ptr;
};
int main(void){
    std::string file="./file";
    std::string dfile="./dump";
    std::ofstream ofs(file);
    A a(file);
    a.output(ofs);
    std::ifstream ifs(dfile);
    A b();
    b.input(ifs);
    return 0;
}
Assume "./file" contains a text below:
The first form (1) returns a string object with a copy of the current contents of the stream.
The second form (2) sets str as the contents of the stream, discarding any previous contents.
I confirmed the content of "./dump" is same as "./file". However, the string object I get(b's *ptr) from b.input("./dump") is just a small string delimitered at space, which is just
The
How can I obtain whole text? Thanks
 
    