Thread: Weird template compilation error with VisualStudio 2005

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248

    Weird template compilation error with VisualStudio 2005

    Hi,

    Just encountered a very weird error while compiling a very simple class template.

    This does not compile:
    Code:
    #ifndef __MATRIX_
    #define __MATRIX_
    
    #include <fstream>
    #include <iostream>
    #include <valarray>
    
    namespace LinearAlgrebra
    {
    
        template<typename T> class Matrix
        {
        public:
    	Matrix();
      
        private:
    	size_t _nbrows;
    	size_t _nbcols;
    	
    	valarray<T> _elms; // vector of column vectors
    	
        }; // end class template
        
    };
    
    #endif
    with the messages
    1>d:\src\pluginlib\inc\LinearAlgebra/Matrix.h(25) : error C2143: syntax error : missing ';' before '<'
    1> d:\src\pluginlib\inc\LinearAlgebra/Matrix.h(27) : see reference to class template instantiation 'LinearAlgrebra::Matrix<T>' being compiled
    1>d:\src\pluginlib\inc\LinearAlgebra/Matrix.h(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\src\pluginlib\inc\LinearAlgebra/Matrix.h(25) : error C2238: unexpected token(s) preceding ';'
    Does it somehow not recognize the 'valarray<T>' ? I really don't understand....
    Last edited by MarkZWEERS; 11-09-2008 at 11:20 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM