Default Constructor compiler error.

S

Sabiyur

Hi All,
While compiling the dll, I am getting the below error.
"error C2512: 'basic_ostream<char,struct std::char_traits<char> >' : no
appropriate default constructor available"

The error is ocucrring on the line "ostream myfile1;"

Does any one know about this error? how to make it go away?. My
requirement is to write some do debug logging into a file. But I am
getting this error.

Please help me.

Thanks
Sabiyur Rahman A
 
M

mlimber

Sabiyur said:
While compiling the dll, I am getting the below error.
"error C2512: 'basic_ostream<char,struct std::char_traits<char> >' : no
appropriate default constructor available"

The error is ocucrring on the line "ostream myfile1;"

Does any one know about this error? how to make it go away?. My
requirement is to write some do debug logging into a file. But I am
getting this error.

You can make it go away by using ostream correctly -- the class does
not have a default constructor (see
http://dinkumware.com/manuals/?manual=compleat&page=ostream.html#basic_ostream).
You probably want to use an object of type std::eek:stringstream or
std::eek:fstream (or similar) instead of std::eek:stream to do your logging.

Cheers! --M
 
J

Jim Langston

Sabiyur said:
Hi All,
While compiling the dll, I am getting the below error.
"error C2512: 'basic_ostream<char,struct std::char_traits<char> >' : no
appropriate default constructor available"

The error is ocucrring on the line "ostream myfile1;"

Does any one know about this error? how to make it go away?. My
requirement is to write some do debug logging into a file. But I am
getting this error.

Please help me.

Thanks
Sabiyur Rahman A

Because ostream requires (on minimum at least, not sure if more is needed)
the file name to write to.

std::eek:stream myfile1("filename.ext");

There is no default constructor for ostream
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top