Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

cpp getter as const

// Return a constant bool. One that cannot change values once it's created
const bool isReady() {
    return ready;
}

// A constant function. One that will not change any mmeber variables of the class it belongs to
// This is the style recommended to use for getters,
// 	since their only purpose is to retrieve data and should not modify anything in the process.
bool getReady() const { 
    return ready;
}

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cpp #getter #const
ADD COMMENT
Topic
Name
7+9 =