What does this mean?

"The separation of the interface to a class from its implementation is crucial to good C++ programming"

This sentence means that the class methods should be separated from its implementation?

What exactly does implementation mean in this context.

I am a bit confused, and I know it is a very simple question, but I am a bit confused lol.
Please, explain first what is the interface of a class.
It is more accurate to say that separating interface from implementation is crucial to good object oriented programming. The interface is what a class exposes to the rest of the program to use (public members and functions). You want a consistent interface that a user (user in this case is a programmer who wants to use your class in his/her code) may invoke and get expected behavior. You don't want the user to have to keep in mind implementation details for your class. Instead, the user should operate only with reasonable expectations about your class and not care how you wrote it.

Say you wrote a class for accessing a simple database. All you may expose are two methods WriteRecordToDatabase and ReadRecordFromDatabase which passes or returns, respectively, some Record struct. The user should not have to care if you are using an SQL database, an Oracle database, or MyOwnFantasticDatabase API to get his/her record into/out of a database. Ideally, you would be able to change your implementation without breaking the user's code at all.

Interface: what the user sees.
Implementation: all the dirty work you do that the user shouldn't see
Thanks :D
Topic archived. No new replies allowed.