How can I rearrange my classes in C + +? [candybox] [class files]

Q: Can someone show me how this program would be split into separate classes so that files Box and candy box are two separate classes? My goal is to Ex8_03.cpp contains only the main function. Box.cpp, Box.h, .cpp, the other would .h files.

Ex8_03.cpp (http://home.nyc.rr.com/pinoy/Ex8_03.cpp be)


Re:the preprocessor directives are so that if you include the same header file more than once, you don't get a complaint about the class being defined more than once. you may not think it's a problem to avoid including the same header more than once, but after you start creating a number of classes that share dependencies, you'll find it harder and harder to avoid. the preprocessor directives are just there to say that it should be processed only once.

Re:Clearly you're a C++ pro. You even put in comments.

I use Microsoft Visual C++ and it automatically adds preprocessor directives to my files like the one I inserted. I notice you do the same but a bit different. Why?


Re:If I was going to do that, it would look like this:

Re:if you're trying to find some way to automate it.. it doesn't exist, as far as i know.

if it's the semantics you're asking for..

in the header..
class ClassName {
public:
return-type method-name(parameters) const-modifier;
];

in the source..
return-type ClassName::method-name(parameters) const-modifier {
// code body
}


Related posts

Leave a comment

0 Comments.

Leave a Reply


click to changeSecurity Code

[ Ctrl + Enter ]