Sunday, June 16, 2019

Digest for comp.lang.c++@googlegroups.com - 10 updates in 4 topics

Manfred <noname@invalid.add>: Jun 16 11:06PM +0200

On 6/16/19 12:23 PM, David Brown wrote:
 
> It is also important to note that C++ is a bit more flexible here.  When
> declaring a class, functions declared within the class can refer to
> members and functions that are declared later in the class.
C# works similar to this last sentence of yours. And, since there are no
header files and all function definitions are inside the class
definition, it becomes common that members can refer to others declared
later.
It is as if it does a two pass compilation, so type checking is ensured.
 
 
  And
Keith Thompson <kst-u@mib.org>: Jun 16 02:24PM -0700


> The source snippet I used is this:
 
> int main(void) { return 45 != foo("Hello", 2.5, 45); }
> int foo(char *x, double y, int z) { return z; }
 
Sorry, I messed that up.
 
"gcc -std=c99" should correctly compile all correct C99 programs.
 
"gcc -std=c99 -pedantic" should do the same and issue all required
diagnostics. In this mode, it should be a conforming C99 compiler.
 
"gcc -std=c99 -pedantic-errors" turns all required diagnostics into
fatal errors.
 
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
Keith Thompson <kst-u@mib.org>: Jun 16 02:26PM -0700

>> some_function();
>> }
 
> In Java / .net that's different because the definition is checked.
 
How is that relevant?
 
Also, when you post a followup please leave the attribution lines in
place for any quoted text.
 
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
Keith Thompson <kst-u@mib.org>: Jun 16 02:27PM -0700

> On 16/06/2019 03:58, Scott wrote:
[...]
>> any form of implicit typing is a bad idea.
 
> It is worth being clear here that implicit declarations don't let you
> use functions properly before declaring them.
 
It's even more worth being clear that C does not permit implicit
declarations, and hasn't since 1999.
 
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
David Brown <david.brown@hesbynett.no>: Jun 16 11:33PM +0200

On 16/06/2019 23:27, Keith Thompson wrote:
>> use functions properly before declaring them.
 
> It's even more worth being clear that C does not permit implicit
> declarations, and hasn't since 1999.
 
Yes of course, but you had already said that. (And C++ has never
permitted them.)
Manfred <noname@invalid.add>: Jun 16 10:48PM +0200

On 6/16/19 10:04 PM, G G wrote:
> GradeBook. Could you please explain. i'm trying to
> understand why it would be necessary, along with
> when it would be used again in a program.
 
One possible source of confusion in the example is that the class
GradeBook does not have any state, so it is not evident that
displayMessage() does not change it, since it does not have any.
Suppose you have some state (e.g. member variables) that is modified by
some other member function, then the use for the 'const' qualifier
becomes evident (and it is very useful too)
 
Moreover, if you declare the object as:
const GradeBook myGradeBook;
 
then the compiler will prevent invocation of non-const methods on it.
G G <gdotone@gmail.com>: Jun 16 02:22PM -0700


> Moreover, if you declare the object as:
> const GradeBook myGradeBook;
 
> then the compiler will prevent invocation of non-const methods on it.
 
 
Thanks.
David Brown <david.brown@hesbynett.no>: Jun 16 11:00PM +0200

On 16/06/2019 17:08, Chris Vine wrote:
 
> But you now state that you are saying something else. Me: "Cooked
> apples are best served with custard." You: "No, pears are best served
> with cream."
 
I think a better analogy would be Me: "Cooked apples are best served
with custard." You: "No, apples are not best served with cream. They
are best served with custard".
 
Let's leave it at that, because I think we agree on the actual technical
points and it helps no one to disagree about how we thought we were
saying different things.
Melzzzzz <Melzzzzz@zzzzz.com>: Jun 16 09:03PM


> Let's leave it at that, because I think we agree on the actual technical
> points and it helps no one to disagree about how we thought we were
> saying different things.
 
You have to show that your claim is right. But it isnt. Besides
destructors, bigger problem is exception handling. Each function have to
install exception handler you have either run time penalty or mem size
penalty.
 
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
Melzzzzz <Melzzzzz@zzzzz.com>: Jun 16 08:29PM


>> Probably shared_pointer can't point to array.
 
> It seems to me a little strange, but this is my opinion.
 
> Is there a way to check if the memory is released in the array version?
It is not properly released...
 
--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: