Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

MCQ

= Array of struct: struct node[10] node[1].value


= Cannot declare a variable inside struct they should be global and stored outside
the struct
= Struct should be global
= If struct/union pointer
ptr a->b
noptr a.b
= Unions will change all values when assignment is done

Syntax

Add 2 programs

#include <iostream>

using namespace std;

int main(){

int a,b,sum;

cin >> a >> b ;

sum = a+b;

cout << "The ans is" <<sum<<endl;

return 0;

cin >>
cout<<

Dynamic memory allocation


eg
a=new *char[2]

delete a

1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism

1. Encasulation

All functions and constants are within the class

2. Abtraction
Constants are hidden and cannot be accessed from the outside

Use getters and setters

void setNumber(int x){


c=x;
}

int getNumber(){

return c

You might also like