error from header file

Joined
Jan 6, 2009
Messages
1
Reaction score
0
I'm a Python programmer. I've just written something in Python which it turns out is running far too slowly, so I've decided to re-write the whole thing in C++ - not just for the speed increase but also because I've been wanting to give C++ a go for some time and this is a good excuse.

Anyhoo, I've hit a wall already! I have two questions if anyone would be so kind as to help me - the first is the problem I'm having and the other is just soemthing I'm wondering about linking (something the Python IDLE doesn't concern itself with!).

In the Python string class there is a method called 'split', which just takes a given string and returns an array of 'pieces' of that string, split up by an arbitrary delimiter. I can't find an equivalent in C++, so I made my own and decided to put it in a seperate file for future use.

I called the files 'stringops.h' and 'stringops.cpp'.

The .h file contains the declaration:

vector<string> split( string, string );

So I run my main.cpp with #include "stringops.h" and use the split function in my main func. But the compiler is giving me the error: expected constructor, destructor, or type conversion before '<' token, which, it tells me, is coming from the declaration I made in the .h file. What? Why? I've tried various things like putting #include <string> and include <vector> in the .h file but nothing is making any difference. Does anyone have an idea what's going wrong here?

Second - just something I don't understand about linking, and I can't find an answer through Google. Say I want to use the opengl library for example, which is gl/gl.h. In the linker this is added as -lopengl32. How on earth are you supposed to know what to put there? Where does this -lopengl32 come from? This is just one example but there are a few libraries I find myself unable to use because I just don't know what I'm supposed to put in the linker.

Anyway, I'm so sorry about the length of this post. I hope someone will get back.

Thank you all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top