Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #29788 > unrolled thread

deep copy or shallow copy?

Started bymbalover2014@gmail.com
First post2014-06-24 10:53 -0700
Last post2014-08-11 00:13 -0700
Articles 20 on this page of 62 — 23 participants

Back to article view | Back to comp.lang.c++


Contents

  deep copy or shallow copy? mbalover2014@gmail.com - 2014-06-24 10:53 -0700
    Re: deep copy or shallow copy? Robert Wessel <robertwessel2@yahoo.com> - 2014-06-24 13:01 -0500
    Re: deep copy or shallow copy? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-06-24 20:19 +0000
      Re: deep copy or shallow copy? drew@furrfu.invalid (Drew Lawson) - 2014-06-26 12:43 +0000
        Re: deep copy or shallow copy? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-07-01 15:23 +0000
    Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-06-24 16:32 -0400
    Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-06-26 04:48 +0000
      Re: deep copy or shallow copy? JiiPee <no@notvalid.com> - 2014-07-18 10:37 +0100
      Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-22 13:28 -0700
        Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-22 16:37 -0400
          Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-23 03:17 -0700
            Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-23 08:47 -0400
              Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-23 14:14 -0700
        Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-23 09:28 +0200
        Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-07-24 05:21 +0000
          Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-25 08:05 -0700
    Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-25 17:53 -0500
      Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-25 19:06 -0400
        Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-25 18:59 -0700
          Re: deep copy or shallow copy? ojackson520@gmail.com - 2014-07-25 23:56 -0700
          Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:35 +0000
            Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-28 15:54 -0500
              Re: deep copy or shallow copy? David Brown <david.brown@hesbynett.no> - 2014-07-29 12:30 +0200
                Re: deep copy or shallow copy? Reinhardt Behm <rbehm@hushmail.com> - 2014-07-29 18:56 +0800
                Re: deep copy or shallow copy? Tobias Müller <troplin@bluewin.ch> - 2014-07-29 12:03 +0000
                Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-29 14:21 +0000
                  Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-29 12:39 -0400
                    Re: deep copy or shallow copy? Martijn Lievaart <m@rtij.nl.invlalid> - 2014-07-29 18:48 +0200
                      Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-29 19:16 +0200
                      Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-29 14:38 -0400
                    Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-29 19:24 +0000
                    Re: deep copy or shallow copy? David Brown <david.brown@hesbynett.no> - 2014-07-30 11:08 +0200
                Re: deep copy or shallow copy? Paavo Helde <myfirstname@osa.pri.ee> - 2014-07-29 15:30 -0500
        Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 01:37 -0500
          Re: deep copy or shallow copy? Ian Collins <ian-news@hotmail.com> - 2014-07-26 20:22 +1200
            Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-26 03:19 -0700
              Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-26 14:34 +0200
            Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 16:56 -0500
              Re: deep copy or shallow copy? Richard Damon <Richard@Damon-Family.org> - 2014-07-26 18:26 -0400
              Re: deep copy or shallow copy? Ian Collins <ian-news@hotmail.com> - 2014-07-27 11:14 +1200
              Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-27 10:54 -0400
                Re: deep copy or shallow copy? "Osmium" <r124c4u102@comcast.net> - 2014-07-27 10:01 -0500
                  Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-27 16:12 -0700
                Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-27 14:35 -0400
                Re: deep copy or shallow copy? Stuart <DerTopper@web.de> - 2014-07-28 17:24 +0200
                  Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-28 12:52 -0400
                    Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 18:43 +0000
              Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:39 +0000
          Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-26 11:34 -0400
            Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 16:59 -0500
      Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:32 +0000
        Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-28 14:28 -0500
          Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-08-04 05:56 +0000
            Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-05 11:41 -0500
              Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-08-07 11:03 +0000
                Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-07 12:29 -0500
          Re: deep copy or shallow copy? Öö Tiib <ootiib@hot.ee> - 2014-08-04 05:02 -0700
            Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-05 11:43 -0500
              Re: deep copy or shallow copy? Öö Tiib <ootiib@hot.ee> - 2014-08-05 17:13 -0700
                Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-06 15:14 -0500
            Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-08-20 20:56 -0700
    Re: deep copy or shallow copy? Mikołaj Małecki <ethouris@gmail.com> - 2014-08-11 00:13 -0700

Page 2 of 4 — ← Prev page 1 [2] 3 4  Next page →


#30143

Fromscott@slp53.sl.home (Scott Lurndal)
Date2014-07-28 13:35 +0000
Message-ID<8ksBv.124614$46.63926@fx19.iad>
In reply to#30115
CHIN Dihedral <dihedral88888@gmail.com> writes:
>On Saturday, July 26, 2014 7:06:28 AM UTC+8, Victor Bazarov wrote:
>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:

>> >     std::vector <myClass *> anObj;
>
>Well in this case I'll ask my coworkers
>to use "panObj" instead of "anObj"
>in the review process.
>
>I knew a lot people hated  
>the MS Hungarian naming conventions,
>but that's the life.

No, it's not _the life_.  Not all the world is MS and I've personally
been lucky in 25 years of C++ development to never run across a project
using that strange notation.    That abomination called CamelCase
lives on, however.

[toc] | [prev] | [next] | [standalone]


#30152

FromLynn McGuire <lmc@winsim.com>
Date2014-07-28 15:54 -0500
Message-ID<lr6da2$4qm$1@dont-email.me>
In reply to#30143
On 7/28/2014 8:35 AM, Scott Lurndal wrote:
> CHIN Dihedral <dihedral88888@gmail.com> writes:
>> On Saturday, July 26, 2014 7:06:28 AM UTC+8, Victor Bazarov wrote:
>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>
>>>>      std::vector <myClass *> anObj;
>>
>> Well in this case I'll ask my coworkers
>> to use "panObj" instead of "anObj"
>> in the review process.
>>
>> I knew a lot people hated
>> the MS Hungarian naming conventions,
>> but that's the life.
>
> No, it's not _the life_.  Not all the world is MS and I've personally
> been lucky in 25 years of C++ development to never run across a project
> using that strange notation.    That abomination called CamelCase
> lives on, however.

Cool, I did not know that the variable naming
convention that we use all over our code had a name.
I wonder about the 42 other styles.  We use a lower
case leading character for locals and function names.
Class names, globals and constants have upper case
leading chacacters.

So much better than the good old fortran days of
all upper case on six bit computers.

Lynn

[toc] | [prev] | [next] | [standalone]


#30155

FromDavid Brown <david.brown@hesbynett.no>
Date2014-07-29 12:30 +0200
Message-ID<lr7t3b$gia$1@dont-email.me>
In reply to#30152
On 28/07/14 22:54, Lynn McGuire wrote:
> On 7/28/2014 8:35 AM, Scott Lurndal wrote:
>> CHIN Dihedral <dihedral88888@gmail.com> writes:
>>> On Saturday, July 26, 2014 7:06:28 AM UTC+8, Victor Bazarov wrote:
>>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>
>>>>>      std::vector <myClass *> anObj;
>>>
>>> Well in this case I'll ask my coworkers
>>> to use "panObj" instead of "anObj"
>>> in the review process.
>>>
>>> I knew a lot people hated
>>> the MS Hungarian naming conventions,
>>> but that's the life.
>>
>> No, it's not _the life_.  Not all the world is MS and I've personally
>> been lucky in 25 years of C++ development to never run across a project
>> using that strange notation.    That abomination called CamelCase
>> lives on, however.
> 
> Cool, I did not know that the variable naming
> convention that we use all over our code had a name.
> I wonder about the 42 other styles.  We use a lower
> case leading character for locals and function names.
> Class names, globals and constants have upper case
> leading chacacters.
> 
> So much better than the good old fortran days of
> all upper case on six bit computers.
> 
> Lynn
> 

There are a few styles with names - camelCase, ALLCAPS, lowercase.  I
don't know about the 40 other styles - is there any name for names with
underscores?

Then there are two varieties of "Hungarian".  There is the "System
Hungarian", with things like "dwParam" meaning "double word parameter"
in Windows terms.  This is mostly despised, especially when you are
using a programming language with a good type system.  The other is
"Apps Hungarian", when you use prefixes to give additional meaning that
is not covered by the type system (such as using "ss" for "safe string"
and "us" for "unsafe string" when both have the same string type).  It
might look ugly, but some people feel it helps.


I seem to remember programming in a variety of Basic where variable
names were not only all upper case - they were only one letter long.

[toc] | [prev] | [next] | [standalone]


#30156

FromReinhardt Behm <rbehm@hushmail.com>
Date2014-07-29 18:56 +0800
Message-ID<lr7ukd$ohc$1@dont-email.me>
In reply to#30155
David Brown wrote:

> On 28/07/14 22:54, Lynn McGuire wrote:
>> On 7/28/2014 8:35 AM, Scott Lurndal wrote:
>>> CHIN Dihedral <dihedral88888@gmail.com> writes:
>>>> On Saturday, July 26, 2014 7:06:28 AM UTC+8, Victor Bazarov wrote:
>>>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>
>>>>>>      std::vector <myClass *> anObj;
>>>>
>>>> Well in this case I'll ask my coworkers
>>>> to use "panObj" instead of "anObj"
>>>> in the review process.
>>>>
>>>> I knew a lot people hated
>>>> the MS Hungarian naming conventions,
>>>> but that's the life.
>>>
>>> No, it's not _the life_.  Not all the world is MS and I've personally
>>> been lucky in 25 years of C++ development to never run across a project
>>> using that strange notation.    That abomination called CamelCase
>>> lives on, however.
>> 
>> Cool, I did not know that the variable naming
>> convention that we use all over our code had a name.
>> I wonder about the 42 other styles.  We use a lower
>> case leading character for locals and function names.
>> Class names, globals and constants have upper case
>> leading chacacters.
>> 
>> So much better than the good old fortran days of
>> all upper case on six bit computers.
>> 
>> Lynn
>> 
> 
> There are a few styles with names - camelCase, ALLCAPS, lowercase.  I
> don't know about the 40 other styles - is there any name for names with
> underscores?
> 
> Then there are two varieties of "Hungarian".  There is the "System
> Hungarian", with things like "dwParam" meaning "double word parameter"
> in Windows terms.  This is mostly despised, especially when you are
> using a programming language with a good type system.  The other is
> "Apps Hungarian", when you use prefixes to give additional meaning that
> is not covered by the type system (such as using "ss" for "safe string"
> and "us" for "unsafe string" when both have the same string type).  It
> might look ugly, but some people feel it helps.
> 
> 
> I seem to remember programming in a variety of Basic where variable
> names were not only all upper case - they were only one letter long.

You had _letters_ ? What a luxury.

-- 
Reinhardt

[toc] | [prev] | [next] | [standalone]


#30157

FromTobias Müller <troplin@bluewin.ch>
Date2014-07-29 12:03 +0000
Message-ID<445116522428328072.061758troplin-bluewin.ch@news.eternal-september.org>
In reply to#30155
David Brown <david.brown@hesbynett.no> wrote: 
> There are a few styles with names - camelCase, ALLCAPS, lowercase.  I
> don't know about the 40 other styles - is there any name for names with
> underscores?

In Rust (www.rust-lang.org) they call it snake_case.

Tobi

[toc] | [prev] | [next] | [standalone]


#30158

Fromscott@slp53.sl.home (Scott Lurndal)
Date2014-07-29 14:21 +0000
Message-ID<X5OBv.127368$46.23078@fx19.iad>
In reply to#30155
David Brown <david.brown@hesbynett.no> writes:
>On 28/07/14 22:54, Lynn McGuire wrote:
>> On 7/28/2014 8:35 AM, Scott Lurndal wrote:
>>> CHIN Dihedral <dihedral88888@gmail.com> writes:
>>>> On Saturday, July 26, 2014 7:06:28 AM UTC+8, Victor Bazarov wrote:
>>>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>
>>>>>>      std::vector <myClass *> anObj;
>>>>
>>>> Well in this case I'll ask my coworkers
>>>> to use "panObj" instead of "anObj"
>>>> in the review process.
>>>>
>>>> I knew a lot people hated
>>>> the MS Hungarian naming conventions,
>>>> but that's the life.
>>>
>>> No, it's not _the life_.  Not all the world is MS and I've personally
>>> been lucky in 25 years of C++ development to never run across a project
>>> using that strange notation.    That abomination called CamelCase
>>> lives on, however.
>> 
>> Cool, I did not know that the variable naming
>> convention that we use all over our code had a name.
>> I wonder about the 42 other styles.  We use a lower
>> case leading character for locals and function names.
>> Class names, globals and constants have upper case
>> leading chacacters.
>> 
>> So much better than the good old fortran days of
>> all upper case on six bit computers.
>> 
>> Lynn
>> 
>
>There are a few styles with names - camelCase, ALLCAPS, lowercase.  I
>don't know about the 40 other styles - is there any name for names with
>underscores?
>
>Then there are two varieties of "Hungarian".  There is the "System
>Hungarian", with things like "dwParam" meaning "double word parameter"
>in Windows terms.  This is mostly despised, especially when you are
>using a programming language with a good type system.  The other is
>"Apps Hungarian", when you use prefixes to give additional meaning that
>is not covered by the type system (such as using "ss" for "safe string"
>and "us" for "unsafe string" when both have the same string type).  It
>might look ugly, but some people feel it helps.
>
>
>I seem to remember programming in a variety of Basic where variable
>names were not only all upper case - they were only one letter long.
>
>

You had variables?  What a luxury!

[toc] | [prev] | [next] | [standalone]


#30159

FromVictor Bazarov <v.bazarov@comcast.invalid>
Date2014-07-29 12:39 -0400
Message-ID<lr8ins$9nq$1@dont-email.me>
In reply to#30158
On 7/29/2014 10:21 AM, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>>  [..]
>> I seem to remember programming in a variety of Basic where variable
>> names were not only all upper case - they were only one letter long.
>
> You had variables?  What a luxury!

You didn't?  What, only registers?  The first device I programmed for 
had fourteen (!) of what was called "memory cells".  I don't recall 
clearly, but I think they were actually numbered...

V
-- 
I do not respond to top-posted replies, please don't ask

[toc] | [prev] | [next] | [standalone]


#30160

FromMartijn Lievaart <m@rtij.nl.invlalid>
Date2014-07-29 18:48 +0200
Message-ID<fsvkab-fos.ln1@news.rtij.nl>
In reply to#30159
On Tue, 29 Jul 2014 12:39:23 -0400, Victor Bazarov wrote:

> On 7/29/2014 10:21 AM, Scott Lurndal wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>>  [..]
>>> I seem to remember programming in a variety of Basic where variable
>>> names were not only all upper case - they were only one letter long.
>>
>> You had variables?  What a luxury!
> 
> You didn't?  What, only registers?  The first device I programmed for
> had fourteen (!) of what was called "memory cells".  I don't recall
> clearly, but I think they were actually numbered...

You had memory cells? Pure luxury! On good days we had an end of wire.

M4

[toc] | [prev] | [next] | [standalone]


#30161

FromWouter van Ooijen <wouter@voti.nl>
Date2014-07-29 19:16 +0200
Message-ID<53d7d700$0$4615$e4fe514c@dreader36.news.xs4all.nl>
In reply to#30160
Martijn Lievaart schreef op 29-Jul-14 6:48 PM:
> On Tue, 29 Jul 2014 12:39:23 -0400, Victor Bazarov wrote:
>
>> On 7/29/2014 10:21 AM, Scott Lurndal wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>>   [..]
>>>> I seem to remember programming in a variety of Basic where variable
>>>> names were not only all upper case - they were only one letter long.
>>>
>>> You had variables?  What a luxury!
>>
>> You didn't?  What, only registers?  The first device I programmed for
>> had fourteen (!) of what was called "memory cells".  I don't recall
>> clearly, but I think they were actually numbered...
>
> You had memory cells? Pure luxury! On good days we had an end of wire.

and the order to shoot yourself in the foot with it?

W

[toc] | [prev] | [next] | [standalone]


#30164

FromVictor Bazarov <v.bazarov@comcast.invalid>
Date2014-07-29 14:38 -0400
Message-ID<lr8pnh$um0$1@dont-email.me>
In reply to#30160
On 7/29/2014 12:48 PM, Martijn Lievaart wrote:
> On Tue, 29 Jul 2014 12:39:23 -0400, Victor Bazarov wrote:
>
>> On 7/29/2014 10:21 AM, Scott Lurndal wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>>   [..]
>>>> I seem to remember programming in a variety of Basic where variable
>>>> names were not only all upper case - they were only one letter long.
>>>
>>> You had variables?  What a luxury!
>>
>> You didn't?  What, only registers?  The first device I programmed for
>> had fourteen (!) of what was called "memory cells".  I don't recall
>> clearly, but I think they were actually numbered...
>
> You had memory cells? Pure luxury! On good days we had an end of wire.
>
> M4

I do realize that I'm one of the younger generation here.  <sigh> Yet I, 
too, some day will grow old.  And for now I'll just watch the masters 
and learn, with the hope to develop similar wisdom some day...

V
-- 
I do not respond to top-posted replies, please don't ask

[toc] | [prev] | [next] | [standalone]


#30165

Fromscott@slp53.sl.home (Scott Lurndal)
Date2014-07-29 19:24 +0000
Message-ID<vxSBv.89585$Y37.38235@fx22.iad>
In reply to#30159
Victor Bazarov <v.bazarov@comcast.invalid> writes:
>On 7/29/2014 10:21 AM, Scott Lurndal wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>>  [..]
>>> I seem to remember programming in a variety of Basic where variable
>>> names were not only all upper case - they were only one letter long.
>>
>> You had variables?  What a luxury!
>
>You didn't?  What, only registers?  The first device I programmed for 
>had fourteen (!) of what was called "memory cells".  I don't recall 
>clearly, but I think they were actually numbered...

More than once, I was feeding in instructions via the console
(switches on a PDP-8, via the maintenance console on the B4955[*]).

I can still do the object code from memory for the B4955

  02a607010000100100100008

Adds 10000 to the 7-digit signed field at address 100 and stores
the result in the 7-digit signed field at address 8 (which is
also treated as index register 1 (IX1)).

[*] Once hot-patched the running operating system at a company
    in Milwaukee running a large ATM network.  Stop the system,
    poke the patch into memory, restart, in less than 45 seconds.

[toc] | [prev] | [next] | [standalone]


#30170

FromDavid Brown <david.brown@hesbynett.no>
Date2014-07-30 11:08 +0200
Message-ID<lracmv$8bo$1@dont-email.me>
In reply to#30159
On 29/07/14 18:39, Victor Bazarov wrote:
> On 7/29/2014 10:21 AM, Scott Lurndal wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>>  [..]
>>> I seem to remember programming in a variety of Basic where variable
>>> names were not only all upper case - they were only one letter long.
>>
>> You had variables?  What a luxury!
> 
> You didn't?  What, only registers?  The first device I programmed for
> had fourteen (!) of what was called "memory cells".  I don't recall
> clearly, but I think they were actually numbered...
> 
> V

About a decade ago I programmed a microcontroller that had no RAM - only
the CPU's 32 8-bit registers.  But there was no problem using these for
variables in C (with names as long as I wanted...).

[toc] | [prev] | [next] | [standalone]


#30166

FromPaavo Helde <myfirstname@osa.pri.ee>
Date2014-07-29 15:30 -0500
Message-ID<XnsA379EF2492CC9myfirstnameosapriee@216.196.109.131>
In reply to#30155
David Brown <david.brown@hesbynett.no> wrote in news:lr7t3b$gia$1@dont-
email.me:
nderscores?
> 
> Then there are two varieties of "Hungarian".  There is the "System
> Hungarian", with things like "dwParam" meaning "double word parameter"
> in Windows terms.  This is mostly despised, especially when you are
> using a programming language with a good type system.  The other is
> "Apps Hungarian", when you use prefixes to give additional meaning that
> is not covered by the type system (such as using "ss" for "safe string"
> and "us" for "unsafe string" when both have the same string type).  It
> might look ugly, but some people feel it helps.

If the language type system does not help (and it would be an overkill to 
develop special classes), then it is indeed sometimes helpful to use 
prefixes or suffixes to distinguish between e.g.:

  - string with no quoting, string with HTML quoting, etc.

  - coordinate along x or along y (I guess most do this anyway, but do 
not consider it Hungarian notation)

  - coordinate relative to the client window or relative to the screen 

  - member variable/local variable/global variable

  - member function assuming that a certain mutex is locked

 etc. There are many aspects in real programs which might be important to 
distinguish and the language can never formalize them all, so the 
Hungarian notation will not go away anytime soon. It's just that it has 
to be applied in places where it makes sense, not for something as silly 
as "dwParam".

Cheers
Paavo

[toc] | [prev] | [next] | [standalone]


#30118

FromLynn McGuire <lmc@winsim.com>
Date2014-07-26 01:37 -0500
Message-ID<lqvidh$2kd$1@dont-email.me>
In reply to#30114
On 7/25/2014 6:06 PM, Victor Bazarov wrote:
> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>> On 6/24/2014 12:53 PM, mbalover2014@gmail.com wrote:
>>> Hi all,
>>>
>>> lets assume that I have a structure defined as
>>>
>>> struct A
>>> {
>>> float arr[100];
>>> }
>>>
>>>
>>> A a1;
>>> A a2;
>>>
>>> // Initialize a1, a2.
>>>
>>> memcpy(&a1,&a2,sizeof(A));
>>>
>>> is it a deep copy or still shallow copy?
>>>
>>> Also how about a2 = a1; is it a deep copy or shallow copy from a1 to a2?
>>>
>>>
>>> Thank you.
>>
>> First, do not use structs in C++ code.  Sadly, we
>> have a lot of old C code that was promoted to C++
>> by changing the .c to a .cpp so we have structs
>> all over the place.
>
> What's wrong with using 'struct'?

I prefer classes.

>> That said, the nice thing about the STL is that it
>> allows you to go shallow or deep.  You can use:
>>     std::vector <myClass> anObj;
>> or
>>     std::vector <myClass *> anObj;
>>
>> We frequently use the pointer variant in order to
>> just make a temporary list of objects subject to
>> some criteria.  Passing around pointers is a lot
>> faster and the corresponding new and delete's for
>> these objects is a very controlled situation.  We
>> have very little memory leakage in our app of
>> 700K lines of C++ code.
>
> So, for the sake of some miniscule (likely guessed, not measured)
> performance gain you risk "very little memory leakage"?  What's the big
> idea, a little leakage is OK, but a little time spent copying object is
> a no-no?
>
> V

Our objects can be up to a couple of hundred megabytes
in size.  We do have a clone method in each class for
copying the object but copying them is a freaking
disaster for our Win32 application.  Win64 is a long
way away for us.

Most of the data in our objects is text for which we
use compression for.  But once uncompressed, we leave
it uncompressed until the user wants to move to a new
dataset.  Too dadgum long to compress / recompress
all the time.

And funny thing is that when we moved from Win16 to
Win32, we wondered what we were going to do with all
this memory.  There is never enough memory!  The first
time I had a memory jump was when UCC replaced their
Univac 1108/32 with a 1108/64.  I thought that 64K of
36 bit words was the cat's meow.  Little did I know
that every memory jump would be followed by bigger
apps very soon after.

Lynn

[toc] | [prev] | [next] | [standalone]


#30120

FromIan Collins <ian-news@hotmail.com>
Date2014-07-26 20:22 +1200
Message-ID<c3h6paFkldlU1@mid.individual.net>
In reply to#30118
Lynn McGuire wrote:
> On 7/25/2014 6:06 PM, Victor Bazarov wrote:
>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>
>>> First, do not use structs in C++ code.  Sadly, we
>>> have a lot of old C code that was promoted to C++
>>> by changing the .c to a .cpp so we have structs
>>> all over the place.
>>
>> What's wrong with using 'struct'?
>
> I prefer classes.

..and the difference is?

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#30122

FromCHIN Dihedral <dihedral88888@gmail.com>
Date2014-07-26 03:19 -0700
Message-ID<105a8b74-c8e7-4113-a27f-b011796804f2@googlegroups.com>
In reply to#30120
On Saturday, July 26, 2014 4:22:01 PM UTC+8, Ian Collins wrote:
> Lynn McGuire wrote:
> 
> > On 7/25/2014 6:06 PM, Victor Bazarov wrote:
> 
> >> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
> 
> >>>
> 
> >>> First, do not use structs in C++ code.  Sadly, we
> 
> >>> have a lot of old C code that was promoted to C++
> 
> >>> by changing the .c to a .cpp so we have structs
> 
> >>> all over the place.
> 
> >>
> 
> >> What's wrong with using 'struct'?
> 
> >
> 
> > I prefer classes.
> 
> 
> 
> ..and the difference is?
> 
> 
> 
> -- 
> 
> Ian Collins

I think there is only one copy of 
some data structure to offer member
functions and class properties
for each instance of a declared class. 

[toc] | [prev] | [next] | [standalone]


#30125

FromWouter van Ooijen <wouter@voti.nl>
Date2014-07-26 14:34 +0200
Message-ID<53d3a051$0$4664$e4fe514c@dreader36.news.xs4all.nl>
In reply to#30122
>>>> What's wrong with using 'struct'?

>>> I prefer classes.

>> ..and the difference is?

> I think there is only one copy of
> some data structure to offer member
> functions and class properties
> for each instance of a declared class.

The *only* different between struct and class is that in a struct the 
default is public:, while in a class it is private:.

Wouter van Ooijen


[toc] | [prev] | [next] | [standalone]


#30130

FromLynn McGuire <lmc@winsim.com>
Date2014-07-26 16:56 -0500
Message-ID<lr188t$cok$1@dont-email.me>
In reply to#30120
On 7/26/2014 3:22 AM, Ian Collins wrote:
> Lynn McGuire wrote:
>> On 7/25/2014 6:06 PM, Victor Bazarov wrote:
>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>>
>>>> First, do not use structs in C++ code.  Sadly, we
>>>> have a lot of old C code that was promoted to C++
>>>> by changing the .c to a .cpp so we have structs
>>>> all over the place.
>>>
>>> What's wrong with using 'struct'?
>>
>> I prefer classes.
>
> ..and the difference is?

Methods and serialization.  We write many structs
to our binary storage file and packing is dadgum
dicey (we ported up to Win32 from Win16).  I would
advise never writing / reading a struct to a
binary file.  Write it's constituents instead.

Lynn

[toc] | [prev] | [next] | [standalone]


#30132

FromRichard Damon <Richard@Damon-Family.org>
Date2014-07-26 18:26 -0400
Message-ID<GWVAv.38445$nx3.11303@fx29.iad>
In reply to#30130
On 7/26/14, 5:56 PM, Lynn McGuire wrote:
> On 7/26/2014 3:22 AM, Ian Collins wrote:
>> Lynn McGuire wrote:
>>> On 7/25/2014 6:06 PM, Victor Bazarov wrote:
>>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>>>
>>>>> First, do not use structs in C++ code.  Sadly, we
>>>>> have a lot of old C code that was promoted to C++
>>>>> by changing the .c to a .cpp so we have structs
>>>>> all over the place.
>>>>
>>>> What's wrong with using 'struct'?
>>>
>>> I prefer classes.
>>
>> ..and the difference is?
>
> Methods and serialization.  We write many structs
> to our binary storage file and packing is dadgum
> dicey (we ported up to Win32 from Win16).  I would
> advise never writing / reading a struct to a
> binary file.  Write it's constituents instead.
>
> Lynn
>

As far as having methods, structs and classes are, by the language 
definition, equal. This also applies to serialization.

One "Rule of thumb" that some people use is that if the item qualifies 
as a "POD" (Plain ole Data), then it is declared as a struct, otherwise 
it is a class. A variation is that "struct" means that the definition is 
compatible with C (so C code could include the definition and use it), 
while a class is used for things that can't be made that way.

I suppose with these definitions, some people might ask why you would 
ever want to cripple a "class" to make it meet the requirements to allow 
it (by the convention, not the language) to be a struct.

[toc] | [prev] | [next] | [standalone]


#30134

FromIan Collins <ian-news@hotmail.com>
Date2014-07-27 11:14 +1200
Message-ID<c3ir2jFr599U1@mid.individual.net>
In reply to#30130
Lynn McGuire wrote:
> On 7/26/2014 3:22 AM, Ian Collins wrote:
>> Lynn McGuire wrote:
>>> On 7/25/2014 6:06 PM, Victor Bazarov wrote:
>>>> On 7/25/2014 6:53 PM, Lynn McGuire wrote:
>>>>>
>>>>> First, do not use structs in C++ code.  Sadly, we
>>>>> have a lot of old C code that was promoted to C++
>>>>> by changing the .c to a .cpp so we have structs
>>>>> all over the place.
>>>>
>>>> What's wrong with using 'struct'?
>>>
>>> I prefer classes.
>>
>> ..and the difference is?
>
> Methods and serialization.

It certainly is not.

> We write many structs
> to our binary storage file and packing is dadgum
> dicey (we ported up to Win32 from Win16).  I would
> advise never writing / reading a struct to a
> binary file.  Write it's constituents instead.

All of the above has nothing to do with the only difference between a 
struct and class, which is member accessibility.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


Page 2 of 4 — ← Prev page 1 [2] 3 4  Next page →

Back to top | Article view | comp.lang.c++


csiph-web