Re: C++ problem

2005-01-31 Thread Oleg Goldshmidt
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

Re: C++ problem

2005-01-31 Thread voguemaster
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

Re: C++ problem

2005-01-31 Thread Shachar Shemesh
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

Re: C++ problem

2005-01-31 Thread Oleg Goldshmidt
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

Re: C++ problem

2005-01-30 Thread Shachar Shemesh
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

Re: C++ problem

2005-01-30 Thread Oleg Goldshmidt
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

Re: C++ problem

2005-01-30 Thread Oleg Goldshmidt
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

Re: C++ problem

2005-01-30 Thread Shachar Shemesh
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,

Re: C++ problem

2005-01-30 Thread Oleg Goldshmidt
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

Re: C++ problem

2005-01-30 Thread Shachar Shemesh
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

Re: C++ problem

2005-01-30 Thread Alex Vinokur
"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

Re: C++ problem

2005-01-30 Thread Alex Vinokur
"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); > > > >

Re: C++ problem

2005-01-30 Thread Alex Vinokur
"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/

Re: Sorry, I forgot about copy constructor (was: Re: C++ problem)

2005-01-30 Thread Alex Vinokur
"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

Re: C++ problem

2005-01-30 Thread Shachar Shemesh
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

Re: C++ problem

2005-01-29 Thread Kobi Cohen-Arazi
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

Sorry, I forgot about copy constructor (was: Re: C++ problem)

2005-01-29 Thread Omer Zak
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: > > >

Re: C++ problem

2005-01-29 Thread Omer Zak
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

C++ problem

2005-01-29 Thread Shachar Shemesh
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

Re: C++: Problem with overloading a constructor when splitting a

2001-11-18 Thread Oleg Goldshmidt
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

Re: C++: Problem with overloading a constructor when splitting a

2001-11-18 Thread Daniel Feiglin
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

Re: C++: Problem with overloading a constructor when splitting a

2001-11-18 Thread Oleg Goldshmidt
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

Re: C++: Problem with overloading a constructor when splitting a

2001-11-18 Thread mulix
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

Re: C++: Problem with overloading a constructor when splitting a

2001-11-18 Thread Dan Kenigsberg
> > > 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. >

Re: C++: Problem with overloading a constructor when splitting asrc file.

2001-11-17 Thread guy keren
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: > >

Re: C++: Problem with overloading a constructor when splitting a src file.

2001-11-17 Thread Shaul Karl
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

Re: C++: Problem with overloading a constructor when splitting a src file.

2001-11-17 Thread guy keren
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

C++: Problem with overloading a constructor when splitting a src file.

2001-11-17 Thread Shaul Karl
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) {

Re: C problem

1999-08-01 Thread Stanislav Malyshev a.k.a Frodo
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

Re: C problem

1999-08-01 Thread Yedidya Bar-david
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

Re: C problem

1999-08-01 Thread Ariel Biener
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

C problem

1999-08-01 Thread Itamar S.-T.
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