organising classes in c++?

J

Jason Carney

hello,

How do I organise my classes in c++? At the moment I have something like
this in a .cpp file

class classname { //class definition
private:
//...
public:
//...stuff
char getchar();
}

char classname::classname getchar() {
return anyhing;
}

and then in a separate header file I placed a copy of the class definition -
obviously not the function implementations.

Is that how classes make their interfaces known to other classes so a class
in another file just includes <"classname.h">. Must I have a separate
header file to the main .cpp file in order to create associations? Does the
main .cpp file have to include the class definition here and in the header
file? When you have lots of classes how do most c++ programmers organise
them, just as described or different?

I would be grateful for any comments as I just want to be clear on these
points.

Thanks in advance for your help :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top