By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,657 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,657 IT Pros & Developers. It's quick & easy.

Template syntax help

P: n/a

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();
}
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dave wrote:
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<int> local;

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

int main()
{
geeker<foo_t> r;

r.func();
}


Victor
Jul 22 '05 #2

P: n/a
"Dave" <be***********@yahoo.com> wrote in message
news:10*************@news.supernews.com...

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?
typename T::template bar_t<int> local;
local.m_var = 42;
cout << local.m_var << endl;
}
};

int main()
{
geeker<foo_t> r;

r.func();
}


--
David Hilsee
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.