473,386 Members | 1,602 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,386 software developers and data experts.

class inside templated class

Hi:
I have a templated class, inside of which I declared another class, as
shown below:

template <class T, int nclass array
{
class subclass
{

};

};

When I try to declare a function that uses subclass as a return value I
get an error. For example:

template <class T, int n>
array<T,n>::subclass function()
{

}

int main()
{
return 0;
}

gives the following error:
main.cpp:4: error: expected constructor, destructor, or type conversion
before 'function'

Im using g++.

Any suggestions?
Thanks

Sep 23 '06 #1
1 1707
ic****@gmail.com wrote:
Hi:
I have a templated class, inside of which I declared another class, as
shown below:

template <class T, int nclass array
{
class subclass
{

};

};

When I try to declare a function that uses subclass as a return value I
get an error. For example:

template <class T, int n>
array<T,n>::subclass function()
make that:

typename array<T,n>::subclass function()
{

}

int main()
{
return 0;
}
Best

Kai-Uwe Bux
Sep 23 '06 #2

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

Similar topics

3
by: tirath | last post by:
Hi all, I have a templated class that derives from a non-templated abstract class. How do I then cast a base class pointer to a <templated> derived class pointer in a generalised fashion? ...
10
by: Alexander Malkis | last post by:
What's the semantical/syntactical difference between two keywords "class" and "typename" (apart from different spelling)? -- Best regards, Alex. PS. To email me, remove "loeschedies" from...
9
by: Jon Wilson | last post by:
I have a class which needs to accumulate data. The way we get this data is by calling a member function which returns float on a number of different objects of different type (they are all the...
6
by: __PPS__ | last post by:
it's ok according to the standard to specialize member function like this: template<class T>struct xxx { void func(); }; template<>bool xxx<int>::func(){ //int version } template<>bool...
7
by: quarup | last post by:
I want to specialize a template function that lives inside a class, but am getting a compile error in VS.net 2003. Here's my code: template <class T> class A { public: template <class U> void...
7
by: mathieu | last post by:
Hello, I did read the FAQ on template(*), since I could not find an answer to my current issue I am posting here. I have tried to summarize my issue in the following code (**). Basically I am...
3
by: toton | last post by:
Hi, I want to specialize template member function of a template class . It is creating some syntax problem .... Can anyone say how to do it ? The class is something like this template<typename...
3
by: Thormod Johansen | last post by:
Hi, What is the correct syntax for defining a templated function inside a template class? Example: template <class T> class myClass { private: T data; public:
5
by: GCRhoads | last post by:
I have some templated functions and I want to write a call wrapper class for it. I also want to pass the function object from this class to some functions that will then call the function...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.