Introduction to C Plus PLus

Add to Favourites
Post to:

Description
Here The concepts of Object Oriented programming is introduced describing the features of OOps and a brief gist is added to each of the features. Im a software Engineer and Ive spent most part of my life teaching and some part coding as a developer. But Ive been truly fascinated with the power of OOPs. More to come in next sessions.

Comments
Presentation Transcript Presentation Transcript

INTRODUCTION : INTRODUCTION C++ as a Object Oriented Programming Language.

Goals : Goals A Brief about Object Oriented Programming using C plus plus. Know about Classes and Objects Construction and Destruction of Objects Calling Member Functions.

Classes : Classes A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.Classes are generally declared using the keyword class, with the following format:class class_name { access_specifier_1: member1; access_specifier_2: member2; ... } object_names;

Slide 4 : class Crectangle { int x, y; public: void set_values (int,int); int area (void); } rect; rect.set_values (3,4); myarea = rect.area();

Slide 5 : Here is the complete example of class CRectangle:// classes example #include using namespace std; class CRectangle { int x, y; public: void set_values (int,int); int area () {return (x*y);} }; void CRectangle::set_values (int a, int b) { x = a; y = b; } int main () { CRectangle rect; rect.set_values (3,4); cout << "area: " << rect.area(); return 0; } area: 12 The most important new thing in this code is the operator of scope (::, two colons) included in the definition of set_values(). It is used to define a member of a class from outside the class definition itself.

Constructors : Constructors CRectangle rect (3,4); CRectangle rectb (5,6); Constructors cannot be called explicitly as if they were regular member functions. They are only executed when a new object of that class is created.

Destructors : Destructors The destructor fulfills the opposite functionality. It is automatically called when an object is destroyed.

Conclusion : Conclusion A class can have data, functions to access this data and how data can be accessed. We learnt how classes and objects are defined and data objects can be constructed as well as memory released.

Want to learn?

Sign up and browse through relevant courses.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
jyoti insan
Certified and experienced IT trainer with 8 years teaching experience
User
5 Members Recommend
20 Followers

Your Facebook Friends on WizIQ

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect