vector definition in Visual C++

Hi,

I am a programming beginnger. I have a code that was created for a unix platform that I am trying to compile on Visual C++

For Example consider the following in a .h file:

#include <vector>
#include<set>
class FMNode
{
       public:
               FMNodeStatus status;
               unsigned int nChanges;
               unsigned int t_stamp;
       public:
               FMNode () : status (USTAT), nChanges (0), t_stamp (INT_MIN) { };
};

typedef vector<FMNode > FMNodeArray ; //this line gives error

class FMPartitioner
{
       public:
set<unsigned int> , cNets, *aNodes; //this line gives error too and I don't understand what does Set do

void initialize (double ratio, Set <unsigned int> * actNodes, vector <FMNode> * nd);  //this one too gives error

And then in the .cpp file:

void
FMPartitioner :: initialize (double ratio, unsigned int *actNodes,
               vector <FMNode> * nd) //gives error ofcourse
nmahmoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
Whar errors exactly?

Just a guess:

#include <vector>
#include<set>
using namespace std;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlexFMCommented:
set is STL container. Each element of it must have unique value.

set<unsigned int> , cNets, *aNodes;

defines set of unsigned int elements (cNets) and pointer to such set (aNodes).
0
jkrCommented:
Alternatively, you could explicitly refer to the 'vector' from the 'std' namespace, e.g.

typedef std::vector<FMNode > FMNodeArray ;

But, using 'using namespace ...' will save a lot of typing.

0
a1programmerCommented:
> what does a set do  ?  
     check this out - http://www.informatik.uni-freiburg.de/~danlee/fun/STL-doc/STL/Set.html#Set


in fmnode.h
----------------------------------------

#include <vector>
#include <set>

using namespace std;

class FMNode
{
       public:
               FMNodeStatus status;
               unsigned int nChanges;
               unsigned int t_stamp;
       public:
               FMNode () : status (USTAT), nChanges (0), t_stamp (INT_MIN) { };
};

typedef vector<FMNode> FMNodeArray;  //this line gives error    <--- notice that this isn't an array.  Call it VFMNode  or something


class FMPartitioner
{
       public:
              set <unsigned int> cNets;  //this line gives error too and I don't understand what does Set do
              set <unsigned int>*aNodes;  
         void initialize (double ratio, Set <unsigned int> * actNodes, vector <FMNode> * nd);  //this one too gives error
};






And then in the .cpp file:
---------------------------------------------------

//you need to include your header file
#include "fmnode.h"

typedef vector<FMNode> VFMNode;   <----------------------------------V            (You can use this from your header file)

void  FMPartitioner :: initialize (double ratio, unsigned int *actNodes,  VFMNode nd) //gives error ofcourse


0
a1programmerCommented:
Here's the sgi docs for a SET.  

it needs to be declared like so:
    set<Key, Compare, Alloc>

http://www.sgi.com/tech/stl/set.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.