I have tried using #include <generic>
and #include <generic.h>
but these are not recognised. I have tried consulting the manual but it does not help me.
So anyone know the correct name for this header file using Bloodshed Dev-C++?
I have tried using #include <generic>
and #include <generic.h>
but these are not recognised. I have tried consulting the manual but it does not help me.
So anyone know the correct name for this header file using Bloodshed Dev-C++?
<generic.h>
is a header from ancient, pre-standard C++. In fact it's old even compared to pre-standard C++. I was used back when C++ was just a precompiler on top of C. Even if you could find a compiler that still supported this, using it would not be a good idea and you would not be learning C++ as it exists today.
Any book that mentions <generic.h>
is probably twenty years out of date. Instead you should choose a book from The Definitive C++ Book Guide and List. If you're just learning to program I recommend Programming: Principals and Practice Using C++. If you're already familiar with programming in other languages then Accelerated C++ should be good.
The latest version of Dev-C++ is very old as well (though not nearly as old as <generic.h>
) and newer, much better, compilers and IDEs are available for free. If you're on Windows then Visual Studio 11 beta should be your first choice. (assuming you're not also on an ancient version of Windows...)
C++ doesn't have generics like Java and C# do. C++ has a similar feature called templates, but there are no special headers to include for that. C++ supports templates intrinsically. You can use template types and functions by mentioning their names, along with the template argument type in angle brackets:
#include <vector>
// declare a variable of type std::vector<int>
std::vector<int> vector_of_ints;
The #include <vector>
is to tell the compiler about the std::vector
template class, not to tell the compiler how to use templates in general.
You can define new template types and functions with the template
keyword:
// declare a function accepting and returning a type to be determined later
template <typename T>
T add_one(T x) {
return x + 1;
}