Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Accessor functions in C++

#include <iostream>
 class ForgetCode {
 public:                     // begin public section
     int getInt();           // accessor function
     void setint (int age);  // accessor function
     void display();         // general function
 private:                    // begin private section
     int itsAge;             // member variable
 };
 
 int ForgetCode ::getInt()
 {
     return itsAge;
 }
 
 void ForgetCode ::setint(int age)
 {
     itsAge = age;
 }
 
 void ForgetCode ::display()
 {
     std::cout << "display.\n";
 }
 
 int main()
 {
     ForgetCode  obj;
     obj.setint(5);
     obj.display();
     std::cout << obj.getInt() << " years old.\n";
     obj.display();
     return 0;
 }