Advertisement

STL in vc6

Started by January 17, 2001 03:07 PM
1 comment, last by Fresh 24 years ago
Hello, I''ve upgraded from vc4 to vc6, and I cant get vectors to work proplerly. The following code worked fine under vc4 (except that it included hp''s implementation of stl as opposed to the one with vc6);

#ifndef _CMETAFORM_H_
#define _CMETAFORM_H_

//include 
#include 
#include "Globals.h"

struct
SMetaformColours {
	int colour;
	int highlight_colour;
	int shadow_colour;
};

class
CMetaform {
protected:
	int x, y, width, height;

	CMetaform *m_pParent;
	
	char caption[255];
	BOOL m_bIsShown;
	BOOL m_bUnclickable;

	SMetaformColours ActiveColours;
	SMetaformColours InactiveColours;

	int colour;
	int highlight_colour;
	int shadow_colour;

	BOOL m_bIsColourMorphing;

	int char_width;
	int char_height;
	int char_slack;
public:
	CMetaform();
	virtual ~CMetaform();

	vector m_SubForms;
	//CPtrList m_SubForms;

	virtual void Initialise(void);
 
and etc... For some odd reason, I get the following errors: cmetaform.h(41) : error C2143: syntax error : missing '';'' before ''<'' cmetaform.h(41) : error C2501: ''vector'' : missing storage-class or type specifiers cmetaform.h(41) : error C2059: syntax error : ''<'' cmetaform.h(41) : error C2238: unexpected token(s) preceding '';'' This is all referring to the line which uses the vector template class. I cant really figure out what''s going on... r. "The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
Also, you need to specify the namespace vector exists in. You can do either:

using namespace std;

which will import the entire std namespace, or

using std::vector;

which only makes the compiler aware of the vector class.

Hope this helps,

Liquid
Advertisement
Easy fix.

vector, as well as all the other common STL templates are in the std namespace. Thus you need to add:
using namespace std;  


or declare the reference to vector as
std::vector m_SubForms  


What's going on is that since vector is in the std namespace, it's not visible to the current scope of your application.

Hope that helps, my STL is *incredibly* rusty.

Ash
================================================
quote: Original post by Fresh

Hello, I've upgraded from vc4 to vc6, and I cant get vectors to work proplerly. The following code worked fine under vc4 (except that it included hp's implementation of stl as opposed to the one with vc6);


Edited by - ashleymatheson on January 17, 2001 5:57:03 PM
Humble,Yet l33t

This topic is closed to new replies.

Advertisement