Shachar Shemesh <[EMAIL PROTECTED]> writes:
> There is no difference between the first a() and the second
> a(). Both are temporary variables of type a generated by an empty
> constructor.
Yes, there is a difference, and I suspect that is what you are
missing. In the first case you create a temp
Couple of points,
1. In normal circumstances the compiler automatically generates a
bitwise copy constructor if none is present. This can be verified
easily. Note that in this case, the copy ctor is declared but not
implemented which means the compiler will not create a default copy
ctor. (Myer
Oleg Goldshmidt wrote:
Well, while it was making the round trip to the list and back, I also
made a trip to the bookshelf to check myself. Item 15 of Scott
Meyers's "Effective C++" confirms what I wrote: temps are const, and
for the reasons I covered. It explicitly says that with a declaration
like
Shachar Shemesh <[EMAIL PROTECTED]> writes:
> Oleg Goldshmidt wrote:
>
> >Oleg Goldshmidt <[EMAIL PROTECTED]> writes:
> >
> >
>
> >> I stand by my posting so far.
>
> >
> >Well, while it was making the round trip to the list and back, I also
> >made a trip to the bookshelf to check myself. Item
Oleg Goldshmidt wrote:
Oleg Goldshmidt <[EMAIL PROTECTED]> writes:
I stand by my posting so far.
Well, while it was making the round trip to the list and back, I also
made a trip to the bookshelf to check myself. Item 15 of Scott
Meyers's "Effective C++" confirms what I wrote: temps are co
Oleg Goldshmidt <[EMAIL PROTECTED]> writes:
> I stand by my posting so far.
Well, while it was making the round trip to the list and back, I also
made a trip to the bookshelf to check myself. Item 15 of Scott
Meyers's "Effective C++" confirms what I wrote: temps are const, and
for the reasons I
Shachar Shemesh <[EMAIL PROTECTED]> writes:
> Oleg Goldshmidt wrote:
>
> >Hi Shachar,
> >
> >Compilers generate const temporaries to prevent accidental passing of
> >such a temporary to a function that would be able to modify its
> >argument. If that were allowed the programmer would be surprized
Oleg Goldshmidt wrote:
Hi Shachar,
Compilers generate const temporaries to prevent accidental passing of
such a temporary to a function that would be able to modify its
argument. If that were allowed the programmer would be surprized
because only the compiler-generated temporary would be modified,
Shachar Shemesh <[EMAIL PROTECTED]> writes:
> Hi all,
>
> Here is a small program for your viewing pleasure:
>
> > class a {
> > public:
> > explicit a(int param);
> >
> > a &operator= ( a &that );
> > };
> >
> > int main()
> > {
> > a var1(3);
> >
> > var1=a(5);
> >
> > retu
Shachar Shemesh wrote:
Hi all,
Here is a small program for your viewing pleasure:
class a {
public:
explicit a(int param);
a &operator= ( a &that );
};
int main()
{
a var1(3);
var1=a(5);
return 0;
}
Somewhat surprisingly, this does not compile:
g++ -Wall -gtestcompile.cc -o
"Alex Vinokur" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
[snip]
> Foo(5) is constant
Sorry, Foo(5) is not constant.
Here is an example.
-- foo.cpp --
#include
using namespace std;
struct Foo
{
int var_;
Foo(int var_i) : var_ (var_i) {}
const Foo& operator= (const
"Shachar Shemesh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi all,
>
> Here is a small program for your viewing pleasure:
>
> > class a {
> > public:
> > explicit a(int param);
> >
> > a &operator= ( a &that );
> > };
> >
> > int main()
> > {
> > a var1(3);
> >
> >
"Shachar Shemesh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I'm wondering WHY temporary implicit variables
> should be considered const. It's clear that the compiler does consider
> them like that.
[snip]
See
http://groups-beta.google.com/group/comp.lang.c++/browse_frm/thread/
"Omer Zak" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Replying to myself, because I forgot one more point:
> From what I remember about C++, you need also a copy constructor in this
> case,
In this case a copy constructor is not invoked.
> because you strive to copy a value to
Omer Zak wrote:
On Sat, 29 Jan 2005, Shachar Shemesh wrote:
Hi all,
Here is a small program for your viewing pleasure:
class a {
public:
explicit a(int param);
What is the meaning of 'explicit' declaration?
Is this a C++ keyword which was added since I learned C++?
Explicit means
Yes, explicit keyword is here long time ago. Get a C++ book from more details.
At the moment, C++ decides that binding a non-const ref to a
temporary is wrong. Thats the problem.
Kobi.
On Sat, 29 Jan 2005 23:04:52 +0200 (EET), Omer Zak <[EMAIL PROTECTED]> wrote:
>
>
> On Sat, 29 Jan 2005, Shac
Replying to myself, because I forgot one more point:
>From what I remember about C++, you need also a copy constructor in this
case, because you strive to copy a value to a variable (and in this
special case, the value is a constant instance of a class).
On Sat, 29 Jan 2005, Omer Zak wrote:
>
>
>
On Sat, 29 Jan 2005, Shachar Shemesh wrote:
> Hi all,
>
> Here is a small program for your viewing pleasure:
>
> > class a {
> > public:
> > explicit a(int param);
What is the meaning of 'explicit' declaration?
Is this a C++ keyword which was added since I learned C++?
> >
> > a &operator
Hi all,
Here is a small program for your viewing pleasure:
class a {
public:
explicit a(int param);
a &operator= ( a &that );
};
int main()
{
a var1(3);
var1=a(5);
return 0;
}
Somewhat surprisingly, this does not compile:
g++ -Wall -gtestcompile.cc -o testcompile
testcompile
Daniel Feiglin <[EMAIL PROTECTED]> writes:
> See discussion on export keyword, p. 205 in The C++ Programming
> Language (3rd edn.), Stroustrup. It should do the job, but I don't
> know in GNU c++ implements it.
No. You get
warning: keyword 'export' not implemented and will be ignored
with gcc
See discussion on export keyword, p. 205 in The C++ Programming Language (3rd
edn.), Stroustrup. It should do the job, but I don't know in GNU c++ implements it.
mulix wrote:
> On Sun, 18 Nov 2001, Dan Kenigsberg wrote:
>
>
>>This may seem an ugly feature of C++, but in fact it is better than
Dan Kenigsberg <[EMAIL PROTECTED]> writes:
> This may seem an ugly feature of C++, but in fact it is better than
> the C counterpart - macros.
Inlined functions are supposed to be a standard C feature in C99. GCC
has had them for years.
> In fact, writing the implementation of inline functions
On Sun, 18 Nov 2001, Dan Kenigsberg wrote:
> This may seem an ugly feature of C++, but in fact it is better than the C
> counterpart - macros. In fact, writing the implementation of inline functions
> in header file is a beautiful gem, comparing to writing the implemetation of
> calss templates i
>
>
> On Sun, 18 Nov 2001, Shaul Karl wrote:
>
> > > you have put an inline function inside a '.cc' file. since it is inline,
> > > it will NOT be included in the object file 'base.cc', and thus, during
> > > link, there base constructor will be undefined. this is your bug - not
> > > g++'s.
>
On Sun, 18 Nov 2001, Shaul Karl wrote:
> > you have put an inline function inside a '.cc' file. since it is inline,
> > it will NOT be included in the object file 'base.cc', and thus, during
> > link, there base constructor will be undefined. this is your bug - not
> > g++'s.
> >
> > fixes:
> >
2001, Shaul Karl wrote:
>
> > Date: Sun, 18 Nov 2001 01:38:10 +0200
> > From: Shaul Karl <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: C++: Problem with overloading a constructor when splitting a
> > src file.
> >
> > Pa
header file.
2. make the function not 'inline'.
guy
On Sun, 18 Nov 2001, Shaul Karl wrote:
> Date: Sun, 18 Nov 2001 01:38:10 +0200
> From: Shaul Karl <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: C++: Problem with overloading a constructor when splitting
Part 1: this works as expected
--
[01:27:40 tmp]$ cat main.cc
#include
#include
using namespace std;
class base
{
public:
base();
base(string &str);
};
class derived : public base
{
public:
derived(string &str) : base(str) {
IST>> [itamar@porthos hashtest]$ gcc math.c
-lm should help
--
[EMAIL PROTECTED] \/ There shall be counsels taken
Stanislav Malyshev /\ Stronger than Morgul-spells
phone +972-3-9316425/\ JRRT LotR.
http://sharat.co.il/frodo/ whois:!SM8333
Hi
Itamar S.-T. wrote:
>
> Compiling the following example program:
> #include
>
> int main(void) {
> double x = sqrt(2.0);
> return 1;
> }
>
> Gives me the following error:
> [itamar@porthos hashtest]$ gcc math.c
> /tmp/cc1Mfpzc.o: I
On Sun, 1 Aug 1999, Itamar S.-T. wrote:
gcc -o math math.c -lm
--Ariel
> Compiling the following example program:
> #include
>
> int main(void) {
> double x = sqrt(2.0);
> return 1;
> }
>
> Gives me the following error:
> [itamar@porthos h
Compiling the following example program:
#include
int main(void) {
double x = sqrt(2.0);
return 1;
}
Gives me the following error:
[itamar@porthos hashtest]$ gcc math.c
/tmp/cc1Mfpzc.o: In function `main':
/tmp/cc1
32 matches
Mail list logo