Non const object call const member function in c++

Опубликовано: 07 Октябрь 2024
на канале: CppNuts
1,427
like

JOIN ME
—————
YouTube 🎬    / @cppnuts  
Patreon 🚀   / cppnuts  

COMPLETE PLAYLIST
————————————
C++ Tutorial For Beginners :
   • Introduction To C++  
STL (Standard Template Library) :
   • STL In C++  
ThreadIng In C++ :    • Multithreading In C++  
Multithreading From Beginning To Advance In C++:    • Multithreading From Beginning To Adva...  
Data Structures:    • Data Structure  
Algorithms:    • Binary Search  
Design Patterns:    • Factory Design Pattern in C++  
Smart Pointers:    • Smart Pointer In C++  
C++14:    • Digit Separator In C++  
C++17:    • std string_view in C++17 | Fastest St...  
C++ All Type Casts:    • static_cast In C++  

INTERVIEW PLAYLIST
————————————
C++ Interview Q&A:    • Structural Padding & Packing In C & C++  
C++ Interview Q&A For Experienced:    • How delete[] Knows How Much  To Deall...  
Linked List Interview Questions:    • Find Kth Node From Back In Singly Lin...  
BST Interview Questions:    • Search Element In Binary Search Tree ...  
Array Interview Questions:    • Reverse An Array  
String Interview Questions:    • Check String Is Palindrome Or Not  
Bit Manipulation Questions:    • Find Set Bit In Integer Number  
Binary Tree Interview Question:    • Invert Binary Tree  
Sorting Algorithms:    • Bubble Sort  
C++ MCQ:    • Video  
C MCQ:    • What printf returns after printing? |...  
C Interview Questions:    • Designated Initialization In C  

QUICK SHORT VIDEOS
————————————-
C++ Short :    • C++ Short Videos  
C Short :    • Shorts C Programming MCQ  

It's about the non constant object is used to call const member function and is it allowed or not ?
Well it is totally allowed because it doesn't harm anyway. It's kind of extra protection saying that the function called is a const function so it is fixed that it won't change the data members.

#cppprogramming #softwareengineer #programming #interview