mutoo
5/29/2013 - 12:11 PM

IntCell_with_explicit.h

#include <iostream>
#include "IntCell.h"

int main(int argc, const char * argv[])
{
    IntCell a;
    a = 13;
    
    std::cout << a.read();
    return 0;
}
class IntCell
{
public:
    IntCell(int initialValue = 0)
        :storedValue(initialValue) {}
    
    int read() const {return storedValue;}
    void write(int x) {storedValue = x;}
    
private:
    int storedValue;
};
class IntCell
{
public:
    explicit IntCell(int initialValue = 0)
        :storedValue(initialValue) {}
    
    int read() const {return storedValue;}
    void write(int x) {storedValue = x;}
    
private:
    int storedValue;
};