KodeKnight
  • Data Structures
    Array Stack Queue Linked List Tree Heap Graph Trie HashTable
  • Algorithms
    Recursion Divide And Conquer Greedy Dynamic Programming Backtracking Randomized Searching Sorting
  • About
    About Resume
  • Tags
  • Categories
  • Companies
  • Difficulty
  • Search
KodeKnight

Search KodeKnight

×
 
Custom Search
Sort by
Relevance
Date

const


Access non const member varible inside a const member function

 Posted on December 5, 2009  (Last modified on August 7, 2020)  |  1 minutes  |  Kinshuk Chandra

class MyClass {
public:
      void F() const {
        const_cast(this)->c = 10;
        //c = 10;
      }
    private :
      int c;

}; 

Other solution is mutable.

kodeknight  const functions  const 

Kinshuk Chandra  • © 2020  •  KodeKnight

Hugo v0.74.3 powered  •  Theme Beautiful Hugo adapted from Beautiful Jekyll