You are on page 1of 3

Shallow copies duplicate as less as possible from a structure.

With a shallow copy, two collections share the individual elements they are not
copied differently in both.
That means single copy sedie between two if clone.
Deep copies duplicate everything. A deep copy will copy even the objects.
A deep copy of a collection is two collections with all of the elements in the o
riginal collection duplicated.
-------------------------------------
Static arrays are created on the stack, and they must have a fixed size.
That means static arrays allocate memory at compile time.
Example : int myArray[100];
Dynamic arrays are created on the heap and we need to allocate and free memory t
o them programmatically.
That means dynamic arrays allocate memory at run time and the memory is allocate
d from heap.
Example to Create Memonry : int* myArray = new int[100];
Example to delete Memory : delete[] myArray;
---------------------------------------
cPtr = &c; True
dPtr = c; False
aPtr = &c; False
bPtr = &a; True
aPtr = cPtr; False
cPtr = dPtr; True
*aPtr = 19; True
*cPtr = *aPtr; True
*dPtr = 20.67; True
*bPtr = dPtr; False
----------------------------------------
class Person
{
public:
Person(int age,long SSN);
Person(); // This is the constructor

private:
long SSN;
string firstName;
string lastName;
int age;
};

// Member functions definitions including constructor
Person::Person(void)
{
cout << "This is default constructor";
}

Person::Person(int age,long SSN)
{
cout << "This is constructor with 2 Arguments";
}
-------------------------------------------
In a procedural programming, modules interact by reading and
writing state that is stored in shared data structures and that
is the only way to do so in procedural
In this you have programs which act on data and they're not usually tightly boun
d.
In an object oriented programming, methods are in the form of objects and
interact by sending messages to other objects using different methodologies.
In this, an object consists of data and the code that is allowed to act on that
data,
and they are very tightly bound.
It is the concept of encapsulation.
Basically, Procedural programming focuses on writing subprograms (procedures/fun
ctions/subroutines)
to perform various tasks required in a problem. Object-oriented programming
focuses on the objects in the problem.
------------------------------------------
#include <stdio.h>
#include <math.h>
int main(int argc, char* argv[]){
int i = 0, sum = 0, n = 0,avg = 0;
FILE *fileInput;
fileInput = fopen("inputFileName.txt", "r");

while(fscanf(fileInput, "%d", &n) != EOF){
sum += n;
i++;
}
avg = (sum / i);
printf("The average is %d.\n", avg);
fclose(fileInput);
return 0;
}
-------------------------------------------
int LinkedList::countNodeDivisibleByTwo()
{
int count= 0;
while(top->data != NULL)
{
if((top->data % 2) == 0)
count++;
}
return count;
}
-----------------------------------------
szqxede ici tqifxarcw gjqieyjqa
-----------------------------------------
Postfix : 23+68*3/-7-5+
Prefix : +23--/*68375
----------------------------------------
3 is added to stack
4 is added to stack
+ is evalualted ( 3 + 4 )
7 is added to stack
7 is added to stack
8 is added to stack
* is evalualted ( 7 * 8 )
56 is added to stack
+ is evaluated ( 56 + 3 )
63 is added to stack
8 is added to stack
6 is added to stack
- is evaluated ( 8 - 6 )
2 is added to stack
+ is evaluated ( 63 + 2 )
65 is added to stack
-----------------------------------------
Prefix :

You might also like