Is this generally accepted as proper formatting for C++ classes? I’ve seen so many different formats for how to code classes while trying to learn them. I’m just wondering what the standard or ‘normal’ way of doing it is.
class Circle
{
private:
double radius;
public:
Circle()
{
radius = 0.0;
}
Circle(double r)
{
radius = r;
}
// MEMBER
void setRadius(double r)
{
radius = r;
}
double getArea()
{
return 3.14159 * radius * radius;
}
};
It’s a matter of taste and consistency. There are many ways in which you can format not just classes, but all parts of the code in general. What’s important is that the code is readable to anyone involved on your project, and follows basic guidelines in your group/workplace/whatever.