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

What is causing this error: expected constructor, destructor, or type conversi

I can not see what is causing this error....
iterator has been defined properly, but the error seems to point to the interator type.

Errors I get with g++ svector.c++ -o svector 2> ./err_txt
gcc version 4.3.2

svector.c++:38: error: expected constructor, destructor, or type conversion before ‘SVector’
svector.c++:53: error: expected constructor, destructor, or type conversion before ‘SVector’
svector.c++:63: error: expected constructor, destructor, or type conversion before ‘SVector’
svector.c++:68: error: expected constructor, destructor, or type conversion before ‘SVector’

Expand|Select|Wrap|Line Numbers
  1. #include <iostream> 
  2. #include <vector>
  3.  
  4. #define comp(a,b) \
  5.        ({ typeof (a) _a = (a); \
  6.            typeof (b) _b = (b); \
  7.          _a > _b ? 1 : (_a < _b ? -1 : 0); })
  8.  
  9. #define TINEY 3
  10.  
  11. using namespace std;
  12.  
  13. template <class T>
  14. class SVector 
  15. public:
  16.    typedef typename vector<T>::iterator iterator;
  17.    typedef typename vector<T>::const_iterator const_iterator;
  18.    SVector() {};
  19.    ~SVector() {};
  20.    iterator put(T);
  21.    T get(iterator);
  22.    T operator[](unsigned int);
  23.    unsigned int size() { v.size(); };
  24.    const_iterator begin()const{return v.begin();};
  25.    const_iterator end()const{return v.end();};
  26.    iterator begin(){return v.begin();};
  27.    iterator end(){return v.end();};
  28. private:
  29.    vector<T> v;
  30.    iterator bsearch(unsigned int, unsigned int, T);
  31.    unsigned int isearch(unsigned int, unsigned int, T);
  32.    iterator push_before(iterator, T);
  33.    iterator push_after(iterator, T); 
  34. };
  35.  
  36.    template <class T>
  37.    iterator SVector<T>::put(T)  //line 38
  38.    {
  39.    }
  40.  
  41.    template <class T>
  42.    T SVector<T>::get(iterator)
  43.    {
  44.    }
  45.  
  46.    template <class T>
  47.    T SVector<T>::operator[](unsigned int)
  48.    {
  49.    }
  50.  
  51.    template <class T>
  52.    iterator SVector<T>::bsearch(unsigned int, unsigned int, T)   // line 53
  53.    {
  54.    }
  55.  
  56.    template <class T>
  57.    unsigned int SVector<T>::isearch(unsigned int, unsigned int, T)
  58.    {  
  59.    }
  60.  
  61.    template <class T>
  62.    iterator SVector<T>::push_before(iterator, T) // line 63
  63.    {
  64.    }
  65.  
  66.    template <class T>
  67.    iterator SVector<T>::push_after(iterator, T) //line 68
  68.    {
  69.    }
  70.  
Mar 11 '10 #1
2 3540
Banfa
9,065 Expert Mod 8TB
You have used the type iterator as the return value. Your code does not define a type iterator at global scope but it does define a type SVector<T>::iterator, is that what you meant to use?
Mar 11 '10 #2
jhn735
1
I am unsure but you could try declaring your iterator functions as: 'vector<T>::iterator SVector<T>::functionname(param)'. I just found myself in a similar situation. The typedef is not global so you probably would have to make the functions of type iterator into functions of type SVector<T>.
Nov 30 '11 #3

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

Similar topics

6
by: Zenon | last post by:
Folks, I cannot figure out why I am getting an error: Error E2303 EngineX.hpp 19: Type name expected. Here is my code. Can you please help? #ifndef EngineX__hpp #define EngineX__hpp ...
2
by: sarah | last post by:
I keep getting the following error: g++ SortedList.cpp SortedList.cpp:260: error: expected constructor, destructor, or type conversion before '*' token SortedList.cpp:260: error: expected `,' or...
5
by: cranium.2003 | last post by:
hi, Here is my code #include <iostream.h> int main() { cout <<"HI"; return 0; } and using following command to compile a C++ program g++ ex1.cpp -o ex1
10
by: Szabolcs Horvát | last post by:
Consider the attached example program: an object of type 'A' is inserted into a 'map<int, Am;'. Why does 'm;' call the copy constructor of 'A' twice in addition to a constructor call? The...
9
by: Trent | last post by:
Here is the error while using Visual Studio 2005 Error 1 error LNK2019: unresolved external symbol "void __cdecl print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced in...
2
by: brasewel | last post by:
Hi guys, I'm getting an error i cannot figure. Here is my code Header file ------------------------------------------------------------------------------------------- #ifndef Clock_H #define...
5
by: amitmool | last post by:
hi, i have used the queue library file and try to use the template as template <class QueueItem> queue <QueueItem>::~queue() // line 25 { } template <class QueueItem> void...
16
by: John Doe | last post by:
Hi, I wrote a small class to enumerate available networks on a smartphone : class CNetwork { public: CNetwork() {}; CNetwork(CString& netName, GUID netguid): _netname(netName),...
3
by: Hill | last post by:
This is an simple map, just an exercise. Who can help me fix this compile issue?Thanks in advance. #include <string> #include <vector> #include <iostream> using std::vector; using std::string;...
1
bajajv
by: bajajv | last post by:
Hi, While implementing CList class, I got linker errors for constructor and destructor. Below is the code - template<class TYPE, class ARG_TYPE = const TYPE&> class CList { protected: struct...
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: 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...
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
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?
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...

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.