START WELL TO END WELL
+92 340 1501700 startwelleducationbhimber@gmail.com Mon – Sat: 8:00 AM – 2:00 PM
Startwell Education logo
StartwellEducation
OOP Lecture 10 of 12

this Pointer aur const Functions

Object-Oriented Programming in C++, explained in easy Roman Urdu.

Real life example

"Mera naam" bolte waqt "mera" this hai. Const = museum ki cheez: dekh sakte ho, chhoo nahi sakte.

Industry example

Banking report: getBalance() const hona chahiye, taake report balance ghalti se na badal de.

C++ code

class Acc {
  double b = 0;
public:
  double get() const { return b; }   // read only
  Acc& add(double x){ b += x; return *this; }
};

What happens when it runs

a.add(100).add(50)
Chain chali: balance = 150

Run the full program in the compiler   Interactive version

Quiz

const member function kya karta hai?

Try it yourself

Write one example of this Pointer aur const Functions from your own home, school or work. Then change the program in the compiler and run it again.

All 12 OOP lectures

  1. Lecture 1: Introduction aur Objects
  2. Lecture 2: Encapsulation aur Interface
  3. Lecture 3: Abstraction, Class, Inheritance
  4. Lecture 4: Inheritance ke Concepts
  5. Lecture 5: Association, Composition, Aggregation
  6. Lecture 6: Polymorphism
  7. Lecture 7: C++ me Class
  8. Lecture 8: Constructor
  9. Lecture 9: Copy Constructor, Destructor, this
  10. Lecture 10: this Pointer aur const Functions
  11. Lecture 11: const, Initializer List, static
  12. Lecture 12: static Functions aur Array of Objects
Admissions Open

Give your child the right start.

Seats are limited. Visit our campus, meet our teachers and see why families trust Startwell Education.