Closed Thread
Results 1 to 4 of 4

Thread: Modern C++ design by Andrei Alexandrescu

  1. #1
    Saint is offline Learning Programmer
    Join Date
    Aug 2006
    Posts
    63
    Rep Power
    0

    Modern C++ design by Andrei Alexandrescu

    I am reading this book and have this code:

    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);
    }
    I get the following error but I don't understand why:

    => g++ p4.cxx
    p4.cxx: In function `To safe_reinterpret_cast(From)':
    p4.cxx:6: syntax error before `static_cast'
    Hi >> Saint

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143
    What are classes To and From?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Saint is offline Learning Programmer
    Join Date
    Aug 2006
    Posts
    63
    Rep Power
    0
    In a class the book provided. Is this where the error is?
    Hi >> Saint

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143
    The problem is: I can't diagnose the problem without knowing how those two classes are related to each other.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Modern Programming Language???
    By valente500 in forum General Programming
    Replies: 10
    Last Post: 06-26-2010, 12:58 PM
  2. Replies: 3
    Last Post: 01-23-2010, 02:36 PM
  3. web site design and development, graphic design and animation
    By rhoan in forum Services for Buy/Sell/Trade
    Replies: 0
    Last Post: 01-10-2009, 07:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts