| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"SC Shin" |
| Date: |
30 Sep 2003 09:36:42 AM |
| Object: |
static function template problem on sun compiler |
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux machine
But I am not able to compile this with error on Sun with forte7 compiler:
line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
1 class Apple
2 {
3 public:
4 static int load();
5 };
6
7 class Banana
8 {
9 public:
10 template<typename EL>
11 void load()
12 {
13 m_banana = EL::load();
14 }
15
16 private:
17 int m_banana;
18 };
19
20 class Peach
21 {
22 public:
23 static void initialize()
24 {
25 m_this = new Peach();
26 m_this->o_banana.load<Apple>();
27 }
28 static Peach* m_this;
29
30 private:
31 Banana o_banana;
32 };
33
34 Peach* Peach::m_this;
35
36 int main()
37 {
38 return 0;
39 }
.
|
|
| User: "Chris Theis" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 12:27:01 PM |
|
|
"SC Shin" <pansion@nate.com> wrote in message
news:276327a5.0309300636.1c2ffd5@posting.google.com...
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux machine
But I am not able to compile this with error on Sun with forte7 compiler:
line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
[SNIP]
You should consider changing your compiler - I've experienced similar
problems with this compiler handling templates. I'm not sure because I
haven't used Sun for a long time but there should be a decent GNU compiler
or some other product available.
regards
Chris
.
|
|
|
|
| User: "WW" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 09:41:20 AM |
|
|
SC Shin wrote:
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux
machine But I am not able to compile this with error on Sun with
forte7 compiler: line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
Cut the line numbers please! You do not refer to them and if the others do
not top post, they don't need to either. But it is impossible to copy paste
and try your code. As for the problem: I might be mistaking (due to the
disturbing line numbers I did not read it all) what you have is what I have
seen already several times myself with Sun compiler. It has something
against member templates, whenever you want to access them via a reference
(be it reference or pointer).
--
WW aka Attila
.
|
|
|
| User: "SC Shin" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 07:37:05 PM |
|
|
"WW" <wolof@freemail.hu> wrote in message news:<blc4m3$rl2$1@phys-news1.kolumbus.fi>...
SC Shin wrote:
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux
machine But I am not able to compile this with error on Sun with
forte7 compiler: line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
Cut the line numbers please! You do not refer to them and if the others do
not top post, they don't need to either. But it is impossible to copy paste
and try your code. As for the problem: I might be mistaking (due to the
disturbing line numbers I did not read it all) what you have is what I have
seen already several times myself with Sun compiler. It has something
against member templates, whenever you want to access them via a reference
(be it reference or pointer).
Thanks WW
Please compile following code and let me know how to solve this problem
class Apple
{
public:
static int load();
};
class Banana
{
public:
template<typename EL>
void load()
{
m_banana = EL::load();
}
private:
int m_banana;
};
class Peach
{
public:
static void initialize()
{
m_this = new Peach();
m_this->o_banana.load<Apple>();
}
static Peach* m_this;
private:
Banana o_banana;
};
Peach* Peach::m_this;
int main()
{
return 0;
}
.
|
|
|
| User: "WW" |
|
| Title: Re: static function template problem on sun compiler |
01 Oct 2003 09:49:09 AM |
|
|
SC Shin wrote:
[SNIP]
Please compile following code and let me know how to solve this
problem
[SNIP]
All I can tell you is what I have told you before. This is an error in the
compiler. I have no idea how can you solve it. When I have met something
similar the only solution was to call the member template on a full object,
not a pointer or a reference or an array element etc. My compiler compiles
it. You may try to put in the template keyword there (it must not be there,
but I have seen compilers requring it), but that might not help:
m_this->o_banana.template load<Apple>();
Must not be there, since neither peach, nor banana, nor the initialize
function is a template... but you can give it a try.
--
WW aka Attila
.
|
|
|
|
|
|
| User: "dslater" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 05:26:02 PM |
|
|
try changing:
template<typename EL>
void load()
{
m_banana = EL::load();
}
to
template <typename EL>
void load(const EL *unused=0)
{
m_banana = EL::load();
}
I know that on the Microsoft compiler, a function template must use
all of the template parameters in the argument list. Perhaps the
forte7 compiler has the same limitation.
pansion@nate.com (SC Shin) wrote in message news:<276327a5.0309300636.1c2ffd5@posting.google.com>...
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux machine
But I am not able to compile this with error on Sun with forte7 compiler:
line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
1 class Apple
2 {
3 public:
4 static int load();
5 };
6
7 class Banana
8 {
9 public:
10 template<typename EL>
11 void load()
12 {
13 m_banana = EL::load();
14 }
15
16 private:
17 int m_banana;
18 };
19
20 class Peach
21 {
22 public:
23 static void initialize()
24 {
25 m_this = new Peach();
26 m_this->o_banana.load<Apple>();
27 }
28 static Peach* m_this;
29
30 private:
31 Banana o_banana;
32 };
33
34 Peach* Peach::m_this;
35
36 int main()
37 {
38 return 0;
39 }
.
|
|
|
| User: "SC Shin" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 09:28:48 PM |
|
|
Thanks for your reply.
But changing code is still same problem on both forte7 and Microsoft compiler
Anaway thanks ^^
DAN_SLATER@YAHOO.COM (dslater) wrote in message news:<2ceda41a.0309301426.60973e67@posting.google.com>...
try changing:
template<typename EL>
void load()
{
m_banana = EL::load();
}
to
template <typename EL>
void load(const EL *unused=0)
{
m_banana = EL::load();
}
I know that on the Microsoft compiler, a function template must use
all of the template parameters in the argument list. Perhaps the
forte7 compiler has the same limitation.
pansion@nate.com (SC Shin) wrote in message news:<276327a5.0309300636.1c2ffd5@posting.google.com>...
Hi, everyone
I've got problem.
I am able to compile following code without error on Compaq, Linux machine
But I am not able to compile this with error on Sun with forte7 compiler:
line 26: Unexpected type name: Apple
Please carefully review following code
And Let me know what problem is and how to solve this problem
1 class Apple
2 {
3 public:
4 static int load();
5 };
6
7 class Banana
8 {
9 public:
10 template<typename EL>
11 void load()
12 {
13 m_banana = EL::load();
14 }
15
16 private:
17 int m_banana;
18 };
19
20 class Peach
21 {
22 public:
23 static void initialize()
24 {
25 m_this = new Peach();
26 m_this->o_banana.load<Apple>();
27 }
28 static Peach* m_this;
29
30 private:
31 Banana o_banana;
32 };
33
34 Peach* Peach::m_this;
35
36 int main()
37 {
38 return 0;
39 }
.
|
|
|
| User: "Kevin Goodsell" |
|
| Title: Re: static function template problem on sun compiler |
30 Sep 2003 09:40:30 PM |
|
|
SC Shin wrote:
Thanks for your reply.
Please don't top-post. Read section 5 of the FAQ for posting guidelines.
http://www.parashift.com/c++-faq-lite/
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
.
|
|
|
|
|
|

|
Related Articles |
|
|