From: "Lev Assinovsky" <LAssinovsky@algorithm.aelita.com>
To: "Jon Vance" <mail@jonvance.com>, <gcc-help@gcc.gnu.org>
Subject: RE: could not convert `obj(5)' to `obj &'
Date: Tue, 11 Nov 2003 17:20:00 -0000 [thread overview]
Message-ID: <3F6F4712B759A34ABD453A8B39C10D62015EE8D4@bagman.edm.com> (raw)
You have to use void printit(const obj& o)
since you pass obj(n) which is considered as a temporary.
----
Lev Assinovsky
Aelita Software Corporation
O&S InTrust Framework Division, Team Leader
ICQ# 165072909
> -----Original Message-----
> From: Jon Vance [mailto:mail@jonvance.com]
> Sent: Tuesday, November 11, 2003 7:45 PM
> To: gcc-help@gcc.gnu.org
> Subject: could not convert `obj(5)' to `obj &'
>
>
>
> I have a bunch of code that used to compile under an older
> version of gcc,
> and will not do so using 2.96. Here is a very simple example of the
> problem I am having:
>
> CODE:
>
> #include <stdio.h>
>
> struct obj
> {
> int i;
>
> obj(int n) : i(n) {}
> };
>
> void printit(obj& o)
> {
> printf("%d\n", o.i);
> }
>
> main()
> {
> printit(obj(5));
> }
>
>
>
> COMPILER ERROR:
>
> g++ t.cpp -o t
> t.cpp: In function `int main ()':
> t.cpp:17: could not convert `obj(5)' to `obj &'
> t.cpp:11: in passing argument 1 of `printit (obj &)'
> make: *** [t] Error 1
>
>
>
> Any ideas?
>
>
next reply other threads:[~2003-11-11 17:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-11 17:20 Lev Assinovsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-11-11 16:45 Jon Vance
2003-11-12 11:40 ` Nathan Sidwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F6F4712B759A34ABD453A8B39C10D62015EE8D4@bagman.edm.com \
--to=lassinovsky@algorithm.aelita.com \
--cc=gcc-help@gcc.gnu.org \
--cc=mail@jonvance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).