Search:

Type: Posts; User: CH1156

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Thank you, I got it working. As for the using...

    Thank you, I got it working. As for the using declarations being in source, so in my .h files i just have #include <vector> #include <whatever> and std::vector and std::whatever, and then in the cpp...
  2. Code will not compile, I have no idea whats going on

    So I added a new class to my project and then when i went to compile I got almost 300 errors, I managed to get it down to 3, but I cant seem to figure out what the issue is, it doesn't seem apparent...
  3. Replies
    8
    Views
    9,157

    Yeah I realized that mistake and removed the for...

    Yeah I realized that mistake and removed the for loop from my first post and that works fine, but with this I want to remove every element where the tuple has a value of 0 for the second element of...
  4. Replies
    8
    Views
    9,157

    If the player has 3 weak potions and they use...

    If the player has 3 weak potions and they use alll of them, how would I remove the tuple element of that item? I cant seem to get it working.


    for (auto& i : mInventory)
    {
    ...
  5. Replies
    8
    Views
    9,157

    Ohhhhhhh, thank you so much, I've been having...

    Ohhhhhhh, thank you so much, I've been having trouble figuring that out.
  6. Replies
    8
    Views
    9,157

    But how does that look in code? thats where im...

    But how does that look in code? thats where im confused. I cant seem to figure out how to get the index of the vector and the tuple, if it was a normal vector i could just do something like:
    ...
  7. Replies
    8
    Views
    9,157

    How to get the index of a vector of tuples

    So in my game the player can use items from their inventory, which is a vector of tuple (
    vector<tuple<Item, int>> mInventory{ 0 };) and in my code I noticed an issue, If the player has a Weak...
  8. bump I've been told this is bad design? not...

    bump I've been told this is bad design? not really sure why though, they didnt specify, to me this was perfectly reasonable solution.
  9. Is this initialization of class variables and object setup correct usage?

    I am working on a console game and I am wondering if this is correct usage and setup of class objects, mainly in main, I think it's ok but idk, it just doesnt feel right, it feels like a kludge to...
  10. Replies
    6
    Views
    3,461

    YES, that is exactly what I wanted to do thank...

    YES, that is exactly what I wanted to do thank you, I struggled with that for so long! I didnt know there was a name for it. I'll do more research on composition to understand it better and see more...
  11. Replies
    6
    Views
    3,461

    bump?

    bump?
  12. Replies
    6
    Views
    3,461

    I could make a Vendor class, since a Vendor has...

    I could make a Vendor class, since a Vendor has both a shop and items, I could inherit these things from that, but what if I had a class that was unrelated to another but needed to compare values to...
  13. Replies
    6
    Views
    3,461

    So how would I make this work? I mean some parts...

    So how would I make this work? I mean some parts of the classes have to interact, I need to be able to check if the player has enough credits to buy an item, so I need to compare players credits to...
  14. Awesome thank you! I'll play around with this and...

    Awesome thank you! I'll play around with this and try to improve on it.
  15. Replies
    6
    Views
    3,461

    How to use class object in other class

    I have some classes and i'm trying to use an Item object in the Shop, I need to setup the items that can be sold but VS keeps giving me errors.


    #include "pch.h"#include <iostream>
    #include...
  16. Help with getting different random numbers in a vector

    I am making a program that "simulates" genetic breakdown in DNA and simulates population growth of a fake group of beings, what I need to do is simulate beings pairing up with male and female and ...
  17. Awesome! thank you.

    Awesome! thank you.
  18. Sure, but I wanted to test out the constructor...

    Sure, but I wanted to test out the constructor inheritance, which is mainly why I made the child classes, I agree they're useless otherwise.
  19. Well, I havent finished writing them yet, I...

    Well, I havent finished writing them yet, I wanted to make sure the constructor copying wasnt doing anything weird before I moved on, they'll all have their own purpose soon enough, this program is...
  20. Ok so here is my updated code with a solution I...

    Ok so here is my updated code with a solution I found after hours of searching:



    #include <iostream>


    class Character
    {
    public:
  21. How to copy a constructor from base to child classes

    While I was writing some code I noticed something:


    In this program



    #include <iostream>
  22. Replies
    9
    Views
    3,887

    So i've been playing with the code for a while...

    So i've been playing with the code for a while now and doing some researcha nd I found this method works, but it seems tedious to do and fix, is there a simpler way?


    #include <iostream>

    class...
  23. Replies
    9
    Views
    3,887

    On top of that, I wanted to add the Discharge...

    On top of that, I wanted to add the Discharge weapon and reload weapon fucntions to Weapon but how do I use them if I cant create an object of it in main?


    #include <iostream>

    class Weapon
    {...
  24. Replies
    9
    Views
    3,887

    Oh I had another question about classes in...

    Oh I had another question about classes in general, its the constructor. The newer versions of C++ allow you to initialize variables right in the class without the constructor:


    class Weapon{
    ...
  25. Replies
    9
    Views
    3,887

    Awesome thank you!

    Awesome thank you!
Results 1 to 25 of 59
Page 1 of 3 1 2 3