| ArcherJake (2) | |
|
I'm certain that this is a very basic question, but i'm hoping for a little guidance. NOTE : I'm NOT looking for the answer to any assigned problems for a college course. Just wanted to get that out of the way. I'm taking a course on C++ programming, and over the course of it I've written a lot of vector manipulation methods (filling, filling with randoms, filling with randoms within a range, a series of sorts, an "is sorted" etc. Very basic stuff I know) I'd like to create a "Vectormanip" that I can use as a local include. Every time I've created a header file up until now it's been part of a class such as "Timer" or the like where I create a "new" (to me anyhow) kind of object with a series of variables etc. So what I'm wondering is... what do I call the "class" for this? Can I leave it blank? I'm not sure since I'm only listing a series of methods and not creating a new data structure. Below is the template I'm using... it's the "class" part that's giving me some pause. #ifndef VECTORMANIP_H #define VECTORMANIP_H /************************************************************/ // System includes #include <string> #include <iostream> /************************************************************/ // Local includes /************************************************************/ // Using declarations /************************************************************/ class { public: private: }; // Place all free function prototypes after the class declaration // Include only functions that act on the class /************************************************************/ #endif /************************************************************/ All the methods work fine, and I'm not looking for any sort of easy answers. This isn't for a project in class... I intend to use it since my prof wants us to only use methods we wrote ourselves. This way I can just include these files and save myself the (admittedly minor) hassle of cut-pasting it into the main .cc file. Plus this just seems like something that would be worth knowing if I want to go further in C++ programming. Thanks in advance for all your help. | |
|
|
|
| Peter87 (3691) | |
| You don't need to have a class definition in the header. | |
|
|
|
| Need4Sleep (532) | |||||||
|
use code tags please, it helps everything look neater and easier to read. If these vectors are just functions, place them inside a .cpp class and either: prototype the functions in a header file make the functions inline and place them all inside your header file. Example: VectorManip.h
VectorManip.cpp
main.cpp
If you have a large amount of functions, i would recommend reading up on namespaces and enclosing them in a namespace. | |||||||
|
|
|||||||
| ArcherJake (2) | |
| Ah, so I can just include the list of methods and not worry about the class? Much appreciated. | |
|
|
|
| Need4Sleep (532) | |
| yep, no class is needed | |
|
|
|