Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Thanked 0 Times in 0 Posts

    Unhappy c++ vector class help needed

    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
    TennisHash( const string & notFound, int size = 101 );
    //TennisHash( const TennisHash & rhs )
    //array( rhs.array ), currentSize( rhs.currentSize ) { }

    void Add();

    void Challenge();

    void Exchange();

    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;



  • #2
    Regular Coder
    Join Date
    Oct 2004
    Thanked 0 Times in 0 Posts
    It seems to compile fine just as you have it posted here, with the constructor in the struct.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts