Dependent types
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Dependent types

  1. #1
    Join Date
    Jul 2008
    Posts
    8

    Dependent types

    In the following code where I'm experimenting with dependent types I'm getting these compiler errors:

    1>c:\users\tanaka\desktop\scripta\consoleapplication3\consoleapplication3\consoleapplication3.cpp(20): error C2146: syntax error : missing ';' before identifier 'testVal'
    1> c:\users\tanaka\desktop\scripta\consoleapplication3\consoleapplication3\consoleapplication3.cpp(29) : see reference to class template instantiation 'tic<testType>' being compiled
    1> with
    1> [
    1> testType=test
    1> ]
    1>c:\users\tanaka\desktop\scripta\consoleapplication3\consoleapplication3\consoleapplication3.cpp(20): error C2838: 'test_Value' : illegal qualified name in member declaration
    1>c:\users\tanaka\desktop\scripta\consoleapplication3\consoleapplication3\consoleapplication3.cpp(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    I'm wondering why this doesn't work. Here is the code:

    #include "stdafx.h"

    class test
    {
    public:

    int size_type;
    int test_Value;
    };

    template<class testType>
    class tic
    {
    public:

    testType t;
    typedef typename testType::test_Value testVal;

    void function ( ) {
    t.size_type;
    }
    };

    int _tmain(int argc, _TCHAR* argv[])
    {
    tic<test> t;
    t.function();


    return 0;
    }

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: Dependent types

    And which one is the line 20? The line 29?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2008
    Posts
    8

    Re: Dependent types

    Quote Originally Posted by VictorN View Post
    And which one is the line 20? The line 29?
    Line 20:

    typedef typename testType::test_Value testVal;

    Line 29:

    tic<test> t;

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: Dependent types

    testType::test_Value is not a type, it's a member variable.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center