I am reading this book and have this code:
I get the following error but I don't understand why:Code:#include <cassert> template <class To, class From> To safe_reinterpret_cast ( From from) { std::assert ( sizeof (From) <= sizeof (To) ); return reinterpret_cast <To> (from); } int main() { char c = 'a'; char* pc = safe_reinterpret_cast <char*> (c); }
=> g++ p4.cxx
p4.cxx: In function `To safe_reinterpret_cast(From)':
p4.cxx:6: syntax error before `static_cast'
Hi >> Saint
What are classes To and From?
In a class the book provided. Is this where the error is?
Hi >> Saint
The problem is: I can't diagnose the problem without knowing how those two classes are related to each other.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks