...

View Full Version : c++ vector class help needed



hotbeard
10-23-2004, 01:43 AM
This is my first post and I need some help constructing a class. The class contains a struct in the private section with a few kinds of data types in it. After the struct is defined, I need to define a vector using that struct as its data type.

I am receiving a compiler error when I include a constructor in the struct.
When there is no constructor in the struct, everything compiles fine. Can someone please clue me in as to what is wrong. Thanks.

PS. I am using MSVC .NET


//header file for Class "Hash"
#ifndef TENNIS_HASH_H
#define TENNIS_HASH_H

#include <iostream>
#include <vector>
#include <string>
using namespace std;









class TennisHash
{
public:
TennisHash( const string & notFound, int size = 101 );
//TennisHash( const TennisHash & rhs )
//: ITEM_NOT_FOUND( rhs.ITEM_NOT_FOUND ),
//array( rhs.array ), currentSize( rhs.currentSize ) { }

void Add();

void Challenge();

void Exchange();



private:
struct HashEntry
{
string Name;
string Challenger;
int Rank;



HashEntry::HashEntry(string & n, string & nc, int r)
{
Name = n;
Challenger = nc;
Rank = r;
}


};

string NextChallenge;
int NextRank;
int TableSize;
const string ITEM_NOT_FOUND;
vector<HashEntry> array;



};



#endif

aman
10-27-2004, 07:27 AM
It seems to compile fine just as you have it posted here, with the constructor in the struct.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum