Anna University Regulation 2013 Electronics and Communication Engineering (ECE) EC6301 OOPS DS Notes for all 5 units are provided below. Download link for ECE 3rd SEM EC6301 Object Oriented Programming n Data Structures Lecture Notes are listed down for students to make perfect utilization and score maximum marks with our study materials.
Accessing Class Members
Data members and member functions can be accessed in similar way the member of structure is accessed using member operator(.). For the class and object defined above, func1() for object obj2 can be called using code: obj2.func1();
Similarly, the data member can be accessed as: object_name.data_memeber;
Reference Variables (Object)
When class is defined, only specification for the object is defined. Object has same relationship to class as variable has with the data type. Objects can be defined in similar way as structure is defined.
Syntax to Define Object in C++ class_name variable name; For the above defined class temp, objects for that class can be defined as: temp obj1, obj2;
Constructor
x It is a special member function of a class , which is used to construct the memory of object & provides initialization.
x Its name is same as class name.
x It must be declared in public part otherwise result will be error.
x It does not return any value not even void otherwise result will be error.
x It can be defined by inline /offline method.
x Does not need to call because it get call automatically whenever object is created.
x It can be called explicitly also.
x It can take parameters.
x Constructer can be overloaded.
x It does not inherit.
Types of constructor
i. default constructor ii. parameterized constructor
iii. default parameterized constructor iv. copy constructor
There is no type of destructor.
Default constructor
A Default constructor is that will either have no parameters, or all the parameters have default values.
Parameterized constructor
These are the constructors with parameter
Copy constructor
These are special type of Constructors which takes an object as argument, and is used to copy values of data members of one object into other object. We will study copy constructors in detail later.
Syntax
class_Name (const class_Name &obj)
{
// body of constructor
}
#include<iostream.h>
using namespace std;
class marks {
public:
int maths;
int science;
//Default Constructor
marks(){
maths=0; science=0;
}
//Copy Constructor
marks(const marks &obj){
maths=obj.maths; science=obj.science;
}
display()
{
cout<<“Maths : ” << maths
cout<<“Science : ” << science;
}
};
Destructor
Destructor is a special class function which destroys the object as soon as the scope of object ends. The destructor is called automatically by the compiler when the object goes out of scope.
The syntax for destructor is same as that for the constructor, the class name is used for the name of destructor, with a tilde ~ sign as prefix to it.
EC6301 OOPS DS Unit 1 notes – Download Here
EC6301 OOPS DS Unit 2 notes – Download Here
EC6301 OOPS DS Unit 3 notes – Download Here
EC6301 OOPS DS Unit 4 notes – Download Here
If you require any other notes/study materials, you can comment in the below section.
Related Links
For EC6301 OOPS DS Previous Year Question Papers – Click here
For EC6301 OOPS DS Question Bank/2marks 16marks with answers – Click here
For EC6301 OOPS DS Important Questions/Answer Key – Click here
Search Terms
Anna University 3rd SEM ECE OOPS DS Lecture Notes
EC6301 Object Oriented Programming n Data Structures Notes free download
Anna University ECE OOPS DS Notes Regulation 2013
EC6301 Notes, OOPS DS Unit wise Lecture Notes – ECE 3rd Semester