-
January 18th, 2014, 12:59 PM
#1
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;
}
-
January 18th, 2014, 01:27 PM
#2
Re: Dependent types
And which one is the line 20? The line 29?
Victor Nijegorodov
-
January 18th, 2014, 01:57 PM
#3
Re: Dependent types
Originally Posted by VictorN
And which one is the line 20? The line 29?
Line 20:
typedef typename testType::test_Value testVal;
Line 29:
tic<test> t;
-
January 18th, 2014, 05:14 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|