473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 }
Jul 19 '05 #1
7 2305
WW
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
Jul 19 '05 #2

"SC Shin" <pa*****@nate.com> wrote in message
news:27*************************@posting.google.co m...
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
Jul 19 '05 #3
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.

pa*****@nate.com (SC Shin) wrote in message news:<27*************************@posting.google.c om>...
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 }

Jul 19 '05 #4
"WW" <wo***@freemail.hu> wrote in message news:<bl**********@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;
}
Jul 19 '05 #5
Thanks for your reply.

But changing code is still same problem on both forte7 and Microsoft compiler

Anaway thanks ^^
DA********@YAHOO.COM (dslater) wrote in message news:<2c**************************@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.

pa*****@nate.com (SC Shin) wrote in message news:<27*************************@posting.google.c om>...
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 }

Jul 19 '05 #6
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.

Jul 19 '05 #7
WW
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
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: ark | last post by:
Hi, If I got it right, C++ deprecates using 'static' keyword for internal linkage in favor of a namespace. I don't understand the equivalence though: namespace assignment does not mechanically...
6
by: Jee | last post by:
Hi, I want to declare a static template member function inside a non-template class, but MS C compiler always complains syntax error. I wonder if it is not allowed to do that? I tried SUN Forte...
3
by: Marco Jez | last post by:
The following code reproduces a problem I'm having with the GCC compiler. It compiles fine on MSVC, so I'm wondering whether it is legal C++ code or not. template<typename C> struct Provider {...
5
by: publictom | last post by:
I just happened to read item 47, "Control Flow", in Exceptional C++ by Herb Sutter (which is based on Guru of the Week 12), just after reading item 33, "Use Inlining Judiciously", in Effective C++...
9
by: Bryan Parkoff | last post by:
I have noticed that C programmers put static keyword beside global variable and global functions in C source codes. I believe that it is not necessary and it is not the practice in C++. Static...
8
by: Markus Henschel | last post by:
Hello, this is a test case of something I just can't explain myself: ...
5
by: mast2as | last post by:
Hi guys Here's the class I try to compile (see below). By itself when I have a test.cc file for example that creates an object which is an instance of the class SpectralProfile, it compiles...
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
5
by: chgans | last post by:
Hi all, I'm having difficulties with some template static member, especially when this member is a template instance, for example: ---- template<typename T> class BaseT { public: static...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.