Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Naming Convention [closed]

What is the widely accepted naming convention for c++ ? (functions, classes, parameters, local variables, namespaces, etc)

like image 775
Verve Innovation Avatar asked Jan 21 '23 14:01

Verve Innovation


2 Answers

I don't think there is a "widely accepted" naming convention in C++. Stroustrup's books and papers generally has the following coding style:

class Shape {
public: // interface to users of Shapes
    virtual void draw() const;
    virtual void rotate(int degrees);
    // ...
protected:  // common data (for implementers of Shapes)
    Point center;
    Color col;
    // ...
};

You also may want to look at popular style guides like The Google C++ Style Guide.

like image 108
Vijay Mathew Avatar answered Jan 30 '23 08:01

Vijay Mathew


It depends somewhat on the platform. For example, MFC applications have a certain naming style (which I happen to follow), others use a different style.

Sort of like different C++ "cultures".

like image 34
Jonathan Wood Avatar answered Jan 30 '23 08:01

Jonathan Wood