Your code that depends on class A will compile faster as it will not have to parse vector's header file each time A's header is included. The application will run a bit slower though, as it'll have to allocate the vector at some point.
Your code that depends on class A will compile faster as it will not have to parse vector's header file each time A's header is included. The application will run a bit slower though, as it'll have to allocate the vector at some point.
I think the forward declaration has to look something like:
Qt Code:
template <class T> class vector;To copy to clipboard, switch view to plain text mode
I'd say it should be "class vector<float>;". I don't see a reason to use a pointer to a vector in this situation, though... It's just asking for trouble and a necessity to write more code.
It doesn't compile; compile gets many error on the first line (like as I missed the ";").Qt Code:
class vector<float>; class Shape { const std::vector<float>* _sides;To copy to clipboard, switch view to plain text mode
I know It's unuseful, but I'd like compile it for study....
thanks.
Regards
Probably because you didn't put it in a namespace. Try:
Qt Code:
namespace std { class vector<float>; }To copy to clipboard, switch view to plain text mode
or:
Qt Code:
namespace std { template <class T> vector; }To copy to clipboard, switch view to plain text mode
nothing to do
Regards
IMHO the pointer shouldn't be const.
What do you mean by "nothing to do"?
Sorry, my english is not correct.....It means that compiler gets the same errors (a lot) on the line "class vector<float>;" (I took off "const" as you suggested) . Of course, if I include vector.h, there aren't problems...I don't understand how to do this forward declaration![]()
Regards
Sorry, I made a mistake in my template declaration. Try:
Qt Code:
namespace std { template <class T> class vector; }To copy to clipboard, switch view to plain text mode
That compiles fine on my computer.
Bookmarks