473,405 Members | 2,279 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,405 software developers and data experts.

typename & inheritance errors also typename & iterator definition errors

In the following code I am trying to create a new templete class (SVector) that is a linked list with the added functionality of an insert method that automatically places items in sorted order.

I am having 2 problems 1) in the statement "class SVector:public list<T>" T is not recognized as per the messages:
svector.c++:21: error: expected template-name before ‘<’ token
svector.c++:21: error: expected `{' before ‘<’ token
svector.c++:21: error: expected unqualified-id before ‘<’ token

2) I can not get the compiler (gcc 4.3.2) to setup typedefs for iterators as per the messages:
svector.c++:36: error: invalid use of template-name ‘std::iterator’ without an argument list



Expand|Select|Wrap|Line Numbers
  1. #include <iostream> 
  2. #include <vector> 
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. class SVector:public list<T>
  8. {  
  9.    typedef typename list<T>::iterator iterator;
  10.    typedef typename list<T>::const_iterator const_iterator;
  11.    SVector() : list<T> v() {}
  12.    ~SVector() { delete v; }
  13. .
  14. .
  15. .
  16.  
  17.  private:
  18.    iterator bsearch(iterator, iterator, T)
  19.    iterator isearch(iterator, iterator, T)
  20. }
  21.  
  22. iterator Svector::isearch(iterator low, iterator high, Type item)
  23. {
  24.     iterator P;
  25.     for (p = low; (*p < item) && (p != high); p++;)
  26.     return p;
  27. }
  28.  
Thanks in advance
Phillip Wyckoff
Mar 7 '10 #1
1 3645
Banfa
9,065 Expert Mod 8TB
You haven't included <list>
Mar 7 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
2
by: Anonymous | last post by:
I'm trying to port code from VC.net to VC.net 2003. Here's a typical piece of code that's often used: template<class T> class PseudoContainer { typedef T::iterator iterator; // this line will...
4
by: Conrad Weyns | last post by:
vc7.1 has no problem with the following snippet: template <typename T> class TTest { std::list<T*>::iterator m_It; }; but metrowerks codewarrior 9.2 kicks my butt and online Comeau confirms:...
4
by: pervinder | last post by:
Hi, I get an error on line #3 while compiling the program segment on aix (xlc - va6) While this warning is not seen with gcc "test.cpp" line 200.18: 1540-0152 (W) A template dependent name that...
1
by: Tony Johansson | last post by:
Hello! What does this mean. "The use of inheritance to provide various implementations of a single abstraction tightly binds these implementations to the abstarction. Therfore it, is difficult...
6
by: PengYu.UT | last post by:
Hi, I'm wondering why typename can not be inherented from base class. An example is shown below. If I have to typedef value_type anyway, I think it would be easier to define the 5 types in...
13
by: Staffan Langin | last post by:
Hello, In the following code-snippet, template<class Base> class Foo : public Base {
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
2
by: Dilip | last post by:
Folks I understand that the keyword typename is also used to indicate that a dependant parameter is a type. However I am a little unsure why I need typename in this following example: ...
2
by: pssraju | last post by:
Hi, At present application was built on solaris 9 using sun studio 9 (Sun C++ 5.6) & rouguewave sorce pro 5. We are planning to port the same application onto SuSE Linux 9.5.0 using GCC 3.3.3 & RW...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.