Basic C++ questions

W

webfan

1. How many types of copy constructor in C++?

2. Will compiler-generated copy constructor do bitwise or memberwise
copying?
 
P

Phlip

webfan said:
1. How many types of copy constructor in C++?

2. Will compiler-generated copy constructor do bitwise or memberwise
copying?

Guessing from 2, the answer to 1 is "compiler-generated or
programmer-supplied."

The answer to 2 is "memberwise".

Is this for a quiz or something?
 
V

Victor Bazarov

webfan said:
1. How many types of copy constructor in C++?

If you refer to possible signatures, then two.
2. Will compiler-generated copy constructor do bitwise or memberwise
copying?

The latter. What book are you reading that doesn't explain those
basic elements of the language?

V
 
R

Ron Natalie

Victor said:
If you refer to possible signatures, then two.

Actually, it can be more. You can have defaulted
args for the other parameters.
The latter. What book are you reading that doesn't explain those
basic elements of the language?
Nothing trully works "bitwise" in C++. The smallest unit of
operation is a byte.
 
V

Victor Bazarov

Ron said:
Actually, it can be more. You can have defaulted
args for the other parameters.

Nothing trully works "bitwise" in C++. The smallest unit of
operation is a byte.

I think & and | and ^ operators work bitwise in C++. That's why they
are called bitwise.

V
 
R

Ron Natalie

I think & and | and ^ operators work bitwise in C++. That's why they
are called bitwise.

But they work on something no smaller than a char.

Actually, with bitfields you can get to smaller items than a char,
but in general bytes are the smallest entity.
 
K

Kai-Uwe Bux

Ron said:
Victor said:
webfan wrote: [snip]
2. Will compiler-generated copy constructor do bitwise or memberwise
copying?

The latter. What book are you reading that doesn't explain those
basic elements of the language?
Nothing trully works "bitwise" in C++. The smallest unit of
operation is a byte.

I think, under the as-if rule, an implementation is allowed to copy,say, a
char or an unsigned int bitwise as long as it makes sure that at the end,
all bits have been copied :)


Best

Kai-Uwe Bux
 
S

Someone

Ron said:
But they work on something no smaller than a char.

Actually, with bitfields you can get to smaller items than a char,
but in general bytes are the smallest entity.

No bird is as small as a fly-bird. Actually, some fly-birds are as
small, but in general birds are bigger than fly-birds.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top