Sponsored Content
Full Discussion: Copying!
Top Forums Programming Copying! Post 302133870 by vishalzone2002 on Monday 27th of August 2007 01:48:13 AM
Old 08-27-2007
The terms "deep copy" and "shallow copy" refer to the way objects are copied, for example, during the invocation of a copy constructor or assignment operator. In a deep copy (also called "memberwise copy"), the copy operation respects object semantics. For example, copying an object that has a member of type std::string ensures that the corresponding std::string in the target object is copy-constructed by the copy constructor of class std::string.


class A
{
string s;
};
A a;
A b;
a=b; //deep copy

When assigning b to a, the compiler-generated assignment operator of class A first invokes the assignment operator of class std::string. Thus, a.s and b.s are well-defined, and they are probably not binary-identical. On the other hand, a shallow copy (also called "bitwise copy") simply copies chunks of memory from one location to another. A memcpy() operation is an example of a shallow copy. Because memcpy() does not respect object semantics, it will not invoke the copy constructor of an object. Therefore, you should never use memcpy() to copy objects. Use it only when copying POD (Plain Old Data) types: ints, floating point numbers, and dumb structs.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

copying

I am using AIX version 5.1 I would like to copy my log files to another directory and timestamp them or add the date to the file name so I can distinguish them apart and keep 4weeks of files in this directory. so I usally do this cp rptlog /dump/backup.log.files I would like the the file... (5 Replies)
Discussion started by: rocker40
5 Replies

2. Programming

copying a file

hello, i have to copy a file from one directory to another directory in linux. how to do this using a c function? kindly ans to my query. thanks (2 Replies)
Discussion started by: svh
2 Replies

3. UNIX for Dummies Questions & Answers

copying a file to another

hi group... needed some help regarding this requirement actually we have a set of zip files in a server we have two types of zip files one as usual .zip extension and one with .zip_m extension... we need to copy the files from .zip_m extension to .zip extension with same file name ... it... (2 Replies)
Discussion started by: madhu_aqua14
2 Replies

4. UNIX for Dummies Questions & Answers

copying file

is there anyway to copy a file which i don't have permission? (1 Reply)
Discussion started by: dakid
1 Replies

5. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

6. UNIX for Dummies Questions & Answers

Please, I need help with copying a file.

Hello. I don't know much about UNIX. Here is a problem I need to resolve. There is a file "file1.txt". It contains the line "End Of Copy" somewhere in the middle. I need to copy file1.txt to another file, "file2.txt" until this line. So, if the "file1.txt" is Line 1 Line 2 Line 3... (3 Replies)
Discussion started by: Eugene
3 Replies

7. Shell Programming and Scripting

Copying only the file name

Hi I just want to copy the file name from the input file. Below is the code I have used but the answer comes with quotation . $ cat test.sh file_name=\'$1\' echo $file_name $ sh test.sh grants.dat 'grants.dat' How do I remove the quotation Thanks (2 Replies)
Discussion started by: Krishnaramjis
2 Replies

8. Shell Programming and Scripting

copying with a certain extension

trying to copy all the files without extension then add "*.txt" but its not working is there any other way and i do not want to use cpio -vdump just want to use copy command FROM=/usr/share/doc TO=/aleza/doc #the follow function copies all the files without extensions call(){ cd $FROM... (3 Replies)
Discussion started by: elginmulizwa
3 Replies

9. Shell Programming and Scripting

Need help in copying the file once

hi all , i had a following problem in my script filename=oas/data/output.txt printf"content1" >> $filename printf"content2" >> $filename printf"content3" >> $filename printf"content4" >> $filename printf"content5" >> $filename printf"content6" >> $filename my contents are different... (6 Replies)
Discussion started by: hemanthsaikumar
6 Replies
FBB::IOStream(3bobcat)					   std::istream and std::ostream				    FBB::IOStream(3bobcat)

NAME
FBB::IOStream - Combines std::istream and std::ostream features SYNOPSIS
#include <bobcat/iostream> Linking option: -lbobcat DESCRIPTION
This class combines the features of the std::istream and std::ostream classes. The std::istream and std::ostream may be physically differ- ent streams. FBB:IOStream objects may, e.g., be associated with streams wrapped around pipes (see, e.g., FBB::IfdStream and FBB::OFd- Stream), to construct bi-directional pipes. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
FBB::IOStreambuf (private inheritance), std::istream, std::ostream CONSTRUCTORS
o IOStream(): The default constructor constructs an empty FBB::IOStream objects. It should not be used before its open member (see below) was called. o IOStream(std::istream &in, std::ostream &out): This constructor associates the IOStream object with a std::istream and a std::ostream. All output operations will be passed on to the std::ostream, all input operations to the std::istream. The streams passed to IOStream should outlive the IOStream object. This constructor performs the actions of the default constructor and then calls the IOStream::open member De copy constructor is avail- able as well. MEMBER FUNCTIONS
All members of std::istream and std::ostream are available, as FBB::IOStream inherits from these classes. Furthermore, when switching between std::istream and std::ostream operations, no intermediate seekg() or seekp() operation will normally be required, since the base classes will normally be associated with physically different streams. o void open(std::istream &in, std::ostream &out): This member (re)associates the IOStream object with a std::istream and a std::ostream. All output operations will be passed on to the std::ostream, all input operations to the std::istream. The streams passed to IOStream() should outlive the IOStream object. If this member is called for an IOStream object already associated with an std::ostream object, the already associated std::ostream object is flushed before setting up the new association. o void clear(): This member clears the error states of the associated std::istream and std::ostream objects. EXAMPLE
See the example provided with process(3bobcat). FILES
bobcat/iostream - defines the class interface SEE ALSO
bobcat(7), ifdstream(3bobcat), iostreambuf(3bobcat), ofdstream(3bobcat), process(3bobcat) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::IOStream(3bobcat)
All times are GMT -4. The time now is 01:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy