Question: What Do You Mean by Redirection ?:: OOP: Copy Constructors
Question: What Do You Mean by Redirection ?:: OOP: Copy Constructors
Answer
With the help of redirection we can change the input output locations of the process ?
C++ calls a copy constructor to make a copy of an object in each of the above cases. If there is
no copy constructor defined for the class, C++ uses the default copy constructor which copies
each field, ie, makes a shallow copy.
A friend function is used for accessing the non-public members of a class. A class can allow non-
member functions and other classes to access its own private data, by making them friends. Thus,
a friend function is an ordinary function or a member of another class
They're related but not totally comparable.
An array is a conceptual data representation consisting of a list of more than one item of a
particular scalar type (int, float, char, structure, etc.) where each element is accessed by its index.
The index can be thought of as a counter or enumerator telling you how many elements you have
to skip over to get to the one you're interested in. Here's where addresses come in ... the location
of a particular element in memory is offset from the so-called base address (i.e. the address of
the starting element) by the value
The C compiler is smart enough to take the sizeof() into account when you do pointer arithmetic,
so you can find the address of the i-th element as (address of base) + i, rather than having to do
the multiplication explicitly.
The idea of element address as offset also accounts for C's use of zero-relative array definitions.
Since the first element is offset by 0 positions from the first element its index in C is 0, not 1.
The second (ordinal) element is offset from the first by 1 position so its index is 1, and so on.
Read more:
http://wiki.answers.com/Q/Difference_between_pointers_and_arrays_in_C#ixzz1G1RqCfE2
Overloading the comparison operators is simple once you’ve learned how to overload the
arithmetic operators.
Because the comparison operators are all binary operators that do not modify their operands, we
will make our overloaded comparison operators friend functions.
Here’s an example Point class from the previous lesson with an overloaded operator== and
operator!=.
view source
print?
01 class Point
02 {
03 private:
05
06 public:
08 {
09 m_dX = dX;
10 m_dY = dY;
11 m_dZ = dZ;
12 }
13
16
20 };
21
23 {
26 cP1.m_dZ == cP2.m_dZ);
27 }
28
32 }