To start you off, here are some assignments, you can do these all in a simple console app. They are just refreshers and maybe new to you as well.
1) Write a function that takes a string, then reverses the string. Here is the signature for the function.
void ReverseString(char buf[], int length); //Now implement this to reverse the string
1a) Write a function that takes a string, then reverses the string. This time use STL, meaning don't write your own algorithm, use STL's algorithm and or std::string to do your reversal.
void ReverseString(std::string &inOut); //Now implement this
2) This task will be a little more complete, will require you to use inheritance, polymorphism, encapsulation as well as the Factory design pattern (You will almost always be asked, what design patterns you know, so it's good to know as many as you can, most entries only know the Singleton pattern).
Write a car dealership website(You wont really be creating a website, this is still a console app and the only GUI is what you display to said console). This website lets users create a custom car. Here is what you get to work with.
Auto //Your abstract base class
Car //Derives from auto
Truck //Derives from auto
AutoFactory //All this class does is create the selected car or truck instance
I'll leave the interface ideas up to you, but to get you started, things like an Engine, or number of doors as an example might be good things to expose in the interface (It doesn't matter).
Create a menu that lets the user selected what kind of auto they would like to build.
I will help you out with the Factory. Lets say everything is implemented, here are some possible choices for the factory:
AutoFactory.h
1 2 3 4 5
|
class AutoFactory{
public:
static Car * MakeCar();
static Truck * MakeTruck();
};
|
This factory uses named functions to create said object. Inside the function memory is allocated for that objects type and a pointer to this memory is returned when the Factory is done with it's work.
Another way to do the factory...
AutoFactory.h
1 2 3 4 5 6 7
|
class AutoFactory{
public:
Auto * MakeAuto(int); //This is the only function exposed in the Factory
private:
static Car * MakeCar();
static Truck * MakeTruck();
};
|
This Factory you would pass in an integer, lets call 1 a car and 2 a truck. Inside MakeAuto, depending on what was passed in as the parameter value, the appropriate call to MakeCar or MakeTruck would then be called. The difference here is that a pointer to the Base class is returned (even though that pointer references a complete derived class object.)
Good luck.