By default members of a class are private not public. If you want to make them public you need to use the public keyword.
class foo
{
int bar;
public:
foo() : bar(10) {}
int getBar() const {return bar; }
}
int main
{
foo temp;
int testBar;
testBar = temp.bar; // error bar is private
testBar = temp.getBar(); // okay getBar() is public
}