473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

where did explicit come from?

I've moved an ATL project (that uses STL) from VC6 to VC7. Of course, it won't
compile. In particular, the line

char *res = (char *)malloc( n );
ostrstream pout = ostrstream( res, n ); <<-- error here

now generates an error:

error C2558: class 'std::ostrstream' : no copy constructor available or copy
constructor is declared 'explicit'

The relevant definition from <strstream> is:
....
_CRTIMP2 ostrstream(char *, streamsize,
ios_base::openmode =
ios_base::out); // construct with static array
How do I fix this? Do I have to extend ostrstream and add my own constructor?
Am I misreading the error message?

/steveA
Steve Alpert
my email Fg**********@vqk.pbz is encrypted with ROT13 (www.rot13.org)
-------------------------------------------
NOTICE OF CONFIDENTIALITY
-------------------------------------------
The information in this email, including attachments, may be confidential
and/or privileged and may contain confidential health information. This
email is intended to be reviewed only by the individual or organization
named as addressee. If you have received this email in error please
notify IDX immediately--by return message to the sender or to
se******@idx.com--and destroy all copies of this message and any
attachments. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of IDX. Confidential health information is protected by state and
federal law, including, but not limited to, the Health Insurance
Portability and Accountability Act of 1996 and related regulations.
Nov 16 '05 #1
2 1108
Stephen Alpert <he**@work.r.us> wrote:
I've moved an ATL project (that uses STL) from VC6 to VC7. Of course, it won't
compile. In particular, the line

char *res = (char *)malloc( n );
ostrstream pout = ostrstream( res, n ); <<-- error here
Do you really want to do this??
It creates a temporary unnamed 'ostrstream'
object and uses that to initialize 'pout'.
now generates an error:

error C2558: class 'std::ostrstream' : no copy constructor available or copy
constructor is declared 'explicit'
While the compiler is allowed to eliminate
the temporary, the copy constructor is
required nevertheless.
The relevant definition from <strstream> is:
...
_CRTIMP2 ostrstream(char *, streamsize,
ios_base::openmode =
ios_base::out); // construct with static array
How do I fix this? Do I have to extend ostrstream and add my own constructor?
Try this:
ostrstream pout( res, n );
Am I misreading the error message?
An 'explicit' is one way that would lead to
this error message. Here, it probably is the
missing copy ctor.
/steveA
Steve Alpert
[...]

Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
Beth Orton
Nov 16 '05 #2
On Wed, 5 Nov 2003 14:36:39 +0100, "Hendrik Schober" <Sp******@gmx.de> wrote:
Stephen Alpert <he**@work.r.us> wrote:
I've moved an ATL project (that uses STL) from VC6 to VC7. Of course, it won't
compile. In particular, the line

char *res = (char *)malloc( n );
ostrstream pout = ostrstream( res, n ); <<-- error here


Do you really want to do this??
It creates a temporary unnamed 'ostrstream'
object and uses that to initialize 'pout'.


....[stuff deleted]...

I found that
ostrstream pout( res, n );
worked just fine. I guess VC6 wasn't so picky!

thanks!
/steveA

Steve Alpert
my email Fg**********@vqk.pbz is encrypted with ROT13 (www.rot13.org)
-------------------------------------------
NOTICE OF CONFIDENTIALITY
-------------------------------------------
The information in this email, including attachments, may be confidential
and/or privileged and may contain confidential health information. This
email is intended to be reviewed only by the individual or organization
named as addressee. If you have received this email in error please
notify IDX immediately--by return message to the sender or to
se******@idx.com--and destroy all copies of this message and any
attachments. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of IDX. Confidential health information is protected by state and
federal law, including, but not limited to, the Health Insurance
Portability and Accountability Act of 1996 and related regulations.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dario | last post by:
Trying to compile the following code-fragment with g++ 2.96: class Entity { private: void * data; public: explicit Entity(int); explicit Entity(Entity &); virtual ~Entity(); void...
1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
6
by: Christoph Bartoschek | last post by:
Hi, gcc 3.4 rejects the following program: class T { public: T() : a(3) {} explicit T(T const & other) : a(other.a) {} private: int a;
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
9
by: Tanmoy Bhattacharya | last post by:
Hi, This is a question about whether I am right that a particular syntactic sugar is missing in C++. Let me explain with an example. Let us say I have a class for complex numbers, and I want...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
17
by: arindam.mukerjee | last post by:
I was running code like: #include <stdio.h> int main() { printf("%f\n", 9/5); return 0; }
1
by: petschy | last post by:
hello, i've run into an error when qualifying a copy ctor 'explicit'. the strange thing is that i get a compiler error only if the class is a template and declare the variable as X<Zx = y....
10
by: jlongstreet | last post by:
Please correct any misconceptions, or voice concerns about this being a stupid idea in general. I was wondering today: why doesn't C++ have explicit typedefs? explicit typedef unsigned int...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.