469,282 Members | 2,007 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

How to use [out] parameters in C++ .NET

I'm trying to use the Graphics::MeasureString method,
which gives two out parameters. Apparently these out
parameters are an invention of C#, but the docs still
show a syntax for C++ (below). However, when I try to
compile, I get "error C2059: syntax error: '['".

Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any
more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);

Documentation:

public: SizeF MeasureString(
String* text,
Font* font,
SizeF layoutArea,
StringFormat* stringFormat,
[
Out
] int* charactersFitted,
[
Out
] int* linesFilled
);
Nov 16 '05 #1
2 4243
> Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any
more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);


Get rid of the '[out]' fragments - they are only for informational purposes
in documentation (they are relevant in MIDL, but illegal in C++).
So it should look like this:
gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), &charsPerLine, &linesFilled);

--
pozdrawia
qb****@zdnet.pl
Anything was possible last night. That was the trouble
with last nights. They were always followed by this mornings.
- Terry Pratchett, "Small Gods"

Nov 16 '05 #2
Great. That worked. Thanks very much for your quick
reply.
-----Original Message-----
Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);
Get rid of the '[out]' fragments - they are only for

informational purposesin documentation (they are relevant in MIDL, but illegal in C++).So it should look like this:
gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), &charsPerLine, &linesFilled);

--
pozdrawia
qb****@zdnet.pl
Anything was possible last night. That was the trouble
with last nights. They were always followed by this mornings. - Terry Pratchett, "Small Gods"
.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Birgit Rahm | last post: by
2 posts views Thread by flycast | last post: by
3 posts views Thread by Jerry Houston | last post: by
8 posts views Thread by Dave Veeneman | last post: by
33 posts views Thread by C# Learner | last post: by
9 posts views Thread by Michi Henning | last post: by
14 posts views Thread by stic | last post: by
2 posts views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.