The result of using the "new" operator is a pointer, or (in Java-speak) a reference. It's a memory address where the real data can be found. The star (*) means, "follow the pointer". In other words, using "*oss" means, "go directly to the data represented by oss". It's the only way to get at what was created when you use the "new" operator.
The arrow operator does something similar. Normally you access an object with the dot, like "foo.print()"; but if foo is a pointer, you'd have to do "(*foo).print()". [You need the star inside parenthesis because of operator precedence.] The arrow is a shortcut: you use it instead of a dot, and the object is automatically dereferenced. So, "(*foo).print()" is the same as "foo->print()".
I was just looking into the use of ostrstream a little more in one of my own projects, and realized that it's actually not supposed to be used anymore. Instead, the preferred method uses a "ostringstream" object instead (found in the "sstream" header). You can just substitute that into my code above, in lieu of "ostrstream".
I guess since the default constructor has no parameters, you could just avoid using "new" altogether. Then you wouldn't have access to a pointer, but directly to the object itself. Then you can use just a plain dot, and no star. Expanding my above code, you would get:
Code:
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
int main(int argc, char** argv) {
std::string filename;
std::ostringstream oss;
std::string s;
std::cout << "FILENAME:";
std::cin >> filename;
std::ifstream input(filename.c_str());
char c;
while(input.get(c)) {
oss << c;
}
s = oss.str();
std::cout << "FILE CONTENTS: " << s;
return 0;
}
Pretty much any book about C or C++ should have more information about pointers, if you're interested. They can be complicated, but they're absolutely vital to do even a little bit of advanced C programming.