Maik Klein
Maik Klein

Reputation: 16148

Naming convention for an abstract class?

I know that the naming convention for an interface is something like IName. But what if I am creating an abstract class?

Should I also write an I in front of the class name?

Upvotes: 10

Views: 23822

Answers (3)

Zelix
Zelix

Reputation: 1984

As opposed to Oracles Java coding conventions, there is no "The" naming convention for C++.

  • If you are working on a project for some company you should follow their naming conventions. If there are no documented conventions - look around the code base and try to follow the swarm, consistency is the key.

  • If you are starting something on your own, many find google's c++ coding conventions as a good start.

Upvotes: 11

OMGtechy
OMGtechy

Reputation: 8220

If you are trying to adhere to a specific naming convention, please name it. As the other answer explains, there is no global "C++ Rule" regarding naming conventions.

If you are using Hungarian notation, I believe that the convention is indeed to prefix 'I' as you did for 'IName'.

Note: Whilst there is no "interface" as such in C++, you can define classes with only pure virtual methods and no member variables.

Upvotes: 7

jmihalicza
jmihalicza

Reputation: 2089

There is no such thing as a global naming convention. At the time you know by what naming convention, you can look up the answer in it.

Upvotes: 3

Related Questions