Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:17:43+00:00 2026-05-31T03:17:43+00:00

Ok so I am experimenting with making a simple game. I have a struct

  • 0

Ok so I am experimenting with making a simple game. I have a struct called Equipment with structs inside it for each part i.e. Helmet, Body, etc. In the Equipment’s constructor I have it make objects of the sub structs and in the sub structs constructors i have them initialize string vectors.

So My problem is that in my main function I create an equipment object but when I try to access for example the woodHelm, I get the compile error: ‘struct Equipment’ has no member named ‘helm’. What am I doing wrong? Or is there another way I can do it better?

Here is my Equipment.h (ignore the other sub structs, i havent initialized them yet):

#ifndef EQUIP_H
#define EQUIP_H
#include <vector>
#include <string>

using namespace std;

struct Equipment{
    Equipment();
    struct Helmet{
    Helmet(){
        const char* tmp[] = {"Wooden Helmet","1",""};
        vector<string> woodHelm (tmp,tmp+3);
        const char* tmp1[] = {"Iron Helmet","2",""};
        vector<string> ironHelm (tmp1,tmp1+3);
        const char* tmp2[] = {"Steel Helmet","3",""};
        vector<string> steelHelm (tmp2,tmp2+3);
        const char* tmp3[] = {"Riginium Helmet","5","str"};
        vector<string> rigHelm (tmp3,tmp3+3);
    }
    };
    struct Shield{
    Shield(){
        vector<string> woodShield ();
        vector<string> ironShield ();
        vector<string> steelShield ();
        vector<string> rigShield ();
    }
    };
    struct Wep{
    Wep(){
        vector<string> woodSword ();
        vector<string> ironSword ();
        vector<string> steelSword ();
        vector<string> rigSword ();
    }
    };
    struct Body{
    Body(){
        vector<string> woodBody ();
        vector<string> ironBody ();
        vector<string> steelBody ();
        vector<string> rigBody ();
    }
    };
    struct Legs{
    Legs(){
        vector<string> woodLegs ();
        vector<string> ironLegs ();
        vector<string> steelLegs ();
        vector<string> rigLegs ();
    }
    };
    struct Feet{
    Feet(){
        vector<string> leatherBoots ();
        vector<string> ironBoots ();
        vector<string> steelBoots ();
        vector<string> steelToeBoots ();
        vector<string> rigBoots ();
    }
    };
};


#endif

Equipment.cpp:

#include <iostream>
#include "Equipment.h"

using namespace std;

Equipment::Equipment(){
    Helmet helm;
    Shield shield;
    Wep wep;
    Body body;
    Legs legs;
    Feet feet;
}

and main.cpp:

#include <iostream>
#include "Player.h"
#include "Equipment.h"
#include "Items.h"
#include "conio.h"

using namespace std;
using namespace conio;

void init();

int main(int argc, char* argv[]){
    /****INIT****/
    Player p(argv[1],10,1,1);
    Equipment equip;
    Items items;

    cout << clrscr() << gotoRowCol(3,5) << "Player Stats: (" << p.getName() << ")";
    cout << gotoRowCol(4,5) << "HP: " << p.getHP() <<
    gotoRowCol(5,5) << "Att: " << p.getAtt() <<
    gotoRowCol(6,5) << "Def: " << p.getDef();

    //this is where it is messing up
    p.addHelm(equip.helm.woodHelm);


    cout << gotoRowCol(20,1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:17:44+00:00Added an answer on May 31, 2026 at 3:17 am

    Well, I would not recommend nesting structs like this — put each at parent level. And why not use “class”? But, what you’re doing is possible. The following bit of code might set you in the right direction:

    #include <iostream>
    
    struct A {
        struct B {
            int c;
            B() {
                c = 1;
            }
        };
    
        B b;
    };
    
    
    int main() {
        A a;
    
        std::cout << a.b.c;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with pop-down menus (inside floating DIVs). Making them appear with onmouseover attributes
I'm currently experimenting with build script, and since I have an ASP.net Web Part
I've been experimenting with making a simple Python web crawler, and I'm using regular
I'm making my first attempt at experimenting with Comet. I developed a very simple
In the effort to learn more about applets and Java, I am experimenting making
I'm experimenting with internationalization by making a Hello World program that uses properties files
I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I've been experimenting with OpenID, and have set up a sample web page to
I am experimenting with making Blackberry widgets but having a little trouble. My first
I'm having a little problem while making a game, and while the problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.