Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: quick question on STL  (Read 777 times)

narakal

  • Bay Watcher
    • View Profile
quick question on STL
« on: February 28, 2010, 11:48:41 am »

OK, basically, I am using Codeblocks IDE for programming something, but while trying to use the Vector class, (by including it), compile errors show up, regarding the syntax.... From what I understand, it may be having sometihng to do with not including a stdhfx? header but I am not sure.... so....anybody have any idea how to fix?
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: quick question on STL
« Reply #1 on: February 28, 2010, 09:54:35 pm »

I don't think you need to include anything besides the vector library...

Can we see some code?  It'd make it a lot easier to help you.  Maybe where you're including and using it... are you using:
Code: [Select]
using namespace std;or std:vector?  The "vector" class is in the std namespace, so you have to do or the other, like with "cout" and "cin".
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

narakal

  • Bay Watcher
    • View Profile
Re: quick question on STL
« Reply #2 on: February 28, 2010, 11:16:00 pm »

um....basically, I found out a little later that my problem was that vector class is not compatible with curses as is... so..... revision to original question, how does one make curses compatible with STL?
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: quick question on STL
« Reply #3 on: March 01, 2010, 08:52:28 am »

I don't know what version of curses you're using, but when using PDCurses is was perfectly compatible.  I use vectors extensively in my rogue-like project, and didn't have to do anything besides including both files.

Code: [Select]
#include <string>
#include <vector>
#include <curses.h>

//Some internal includes for other class headers and such...

using namespace std;

class c_player
{
    private:
        string name;

        //Lots of other code...

        vector<string> message_log;

        vector<c_effect> effects;
    public:
        //Lots more code...
};
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

narakal

  • Bay Watcher
    • View Profile
Re: quick question on STL
« Reply #4 on: March 03, 2010, 07:41:27 pm »

eh.....just realized what could have been done to fix it....
Basically, when I had included headers, I included Curses before Vectors.
Thus, causing like....30 different errors..yeah. fixed it mostly now. So....lol?
Logged

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: quick question on STL
« Reply #5 on: March 03, 2010, 08:48:43 pm »

This may happen when one header you're including influences names from a standard header (like cstdio, for example).  Make sure you include the standart library headers before any other external library to avoid this kind of problems. 

It happens for example with OpenGl's Glut and cstdio.
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.