Template syntax help

D

Dave

Hello,

Thanks for your help on the short problem shown below.

Thanks!
Dave


#include <iostream>

using namespace std;

struct foo_t
{
template <typename T>
struct bar_t
{
T m_var;
};
};

template <typename T>
struct geeker
{
void func()
{
T::bar_t<int> local; // Error here!

local.m_var = 42;
cout << local.m_var << endl;
}
};

int main()
{
geeker<foo_t> r;

r.func();
}
 
V

Victor Bazarov

Dave said:
Thanks for your help on the short problem shown below.

Thanks!
Dave


#include <iostream>

using namespace std;

struct foo_t
{
template <typename T>
struct bar_t
{
T m_var;
};
};

template <typename T>
struct geeker
{
void func()
{
T::bar_t<int> local; // Error here!

typename T::bar_t said:
local.m_var = 42;
cout << local.m_var << endl;
}
};

int main()
{
geeker<foo_t> r;

r.func();
}

Victor
 
D

David Hilsee

Dave said:
Hello,

Thanks for your help on the short problem shown below.

Thanks!
Dave


#include <iostream>

using namespace std;

struct foo_t
{
template <typename T>
struct bar_t
{
T m_var;
};
};

template <typename T>
struct geeker
{
void func()
{
T::bar_t<int> local; // Error here!

// How's this for ugly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top