Search:

Type: Posts; User: kbro3

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    1,754

    Hey dwks, Thanks for the quick reply and also...

    Hey dwks,

    Thanks for the quick reply and also for your suggestion, you're right, my code isn't the cleanest in the slightest, and using a switch would make a lot more sense for a menu. :)
    ...
  2. Replies
    2
    Views
    1,754

    Functions calling other functions.

    Hi guys, a bit of a lengthy post, but bear with me please:

    I've had a small problem in my program where I declared functions for a simple menu.
    There are several menus that are embedded - that...
  3. Replies
    10
    Views
    2,382

    Ah thanks for that, did not realise the member...

    Ah thanks for that, did not realise the member objects are created automatically, but I tried it and as you said, it works.

    I'm very new to C++ and have not yet played with an initialisation...
  4. Replies
    10
    Views
    2,382

    Thanks, I created a getter in Orc, called...

    Thanks, I created a getter in Orc, called getWeaponDescription, this is what I wrote:




    string Orc::getWeaponDescription()
    {

    return weapon1.getDescription();
  5. Replies
    10
    Views
    2,382

    Ah crap, yes I see what you mean. getDescription...

    Ah crap, yes I see what you mean. getDescription is a public function of Weapon object. But I listed Weapon object as a private attribute of Orc, so i would not be able to call its' public methods...
  6. Replies
    10
    Views
    2,382

    Yes, I do want to default construct the Weapon...

    Yes, I do want to default construct the Weapon object. Don't I need to call the constructor? (that's what I tried to do in the code). Are you saying that a default weapon object would be created...
  7. Replies
    10
    Views
    2,382

    Objects as attributes of other objects.

    Hi guys,

    Just having a small problem with something i'm playing around with.

    Basically, I have two classes, an Orc class that creates Orc objects, and a Weapon class that creates Weapon...
  8. Replies
    23
    Views
    4,395

    Ah yes, got it. So there are no, or at least...

    Ah yes, got it. So there are no, or at least minimal performance overheads in having several includes?

    Thanks for taking the time to explain the logic behind the code, that's what I was after! :)
  9. Replies
    23
    Views
    4,395

    Sorry to bring this up again, just wanted to get...

    Sorry to bring this up again, just wanted to get everything working the right way, not interested in bad code to make things work.

    I checked command line options, and found how to "link" the...
  10. Replies
    23
    Views
    4,395

    Ah great, yes I thought that it was strange to...

    Ah great, yes I thought that it was strange to include the .cpp instead of .h, seeing as one of the points of header files is to "hide" the implementation of classes while allowing their use.
    And of...
  11. Replies
    23
    Views
    4,395

    Okay, so instead of using namespace std, I should...

    Okay, so instead of using namespace std, I should use std:string for string types? Also, to avoid including the person.cpp in my driver, I compile person.cpp, then compile the driver, then somehow...
  12. Replies
    23
    Views
    4,395

    Okay, got everything to work, Turns out I...

    Okay, got everything to work,

    Turns out I needed to #include <string> in Person.h and also do using namespace std in Person.h

    I then compiled person.cpp (not to executable, but just compile and...
  13. Replies
    23
    Views
    4,395

    Ah cheers, so if I create a driver with a main...

    Ah cheers, so if I create a driver with a main function, and compile that, it will compile everything?

    Or, should I use a different option in the compiler, so that it doesn't build an executable,...
  14. Replies
    23
    Views
    4,395

    Okay, i've included a string in my Person.h AND...

    Okay, i've included a string in my Person.h AND Person.cpp

    (#include <string>)

    I also removed the const and std::string, replaced with a using namespace std

    in BOTH Person.h and Person.cpp
    ...
  15. Replies
    23
    Views
    4,395

    Ok, yeah I see I forgot to put the right...

    Ok, yeah I see I forgot to put the right parameters into the setAge() member function.

    Here's a question, instead of qualifying string with std::string everywhere, as you mentioned I can use the...
  16. Replies
    23
    Views
    4,395

    Thanks for your help, unfortunately that doesn't...

    Thanks for your help, unfortunately that doesn't compile either.

    I now get:

    error: expected `)' before 'name'
    error: 'string' does not have a type
    error: prototype for 'char Person::getSex()'...
  17. Replies
    23
    Views
    4,395

    Yeah sorry, should have included the error...

    Yeah sorry, should have included the error message:

    'string' does not name a type
    expected ')' before 'name'

    In constructor 'Person::Person()' :
    'name' was not declared in this scope
    At...
  18. Replies
    23
    Views
    4,395

    Classes in header files - compile-time errors.

    Hi guys,

    I'm very new to C++, although have some experience in Java.
    Anyway, I'm currently learning about separating code through header files (for class declarations) and storing the...
  19. Replies
    16
    Views
    3,283

    I'm required by assignment guidelines to use char...

    I'm required by assignment guidelines to use char arrays... :(

    -Kirill
  20. Replies
    16
    Views
    3,283

    This is strange. Could the fact it's in...

    This is strange.

    Could the fact it's in separate files be the problem? But then again, it does see the function, and does return something.. just not the whole array.. i'm super confused. Btw, i'm...
  21. Replies
    16
    Views
    3,283

    Absolutely, what i quoted here is EXACTLY my...

    Absolutely, what i quoted here is EXACTLY my code. It still doesn't work, now i've updated the getLastName() function, so now i'm getting returns of 0 for first name and nothing for last name!

    :(...
  22. Replies
    16
    Views
    3,283

    Ah okay, i'll post up my whole project, because I...

    Ah okay, i'll post up my whole project, because I haven't got that much code at the moment anyways:

    This is game.cpp (the driver, and where everything will happen:)




    #include <iostream>...
  23. Replies
    16
    Views
    3,283

    Okay, there are three files in my project,...

    Okay, there are three files in my project, Player.h (Player class, where playerFirstName) Player.cpp (definitions of functions from Player.h) and maingame.cpp (main driver)

    maingame.cpp call the...
  24. Replies
    16
    Views
    3,283

    Tried this, now i'm getting 0.. :( char*...

    Tried this, now i'm getting 0.. :(




    char* Player::getFirstName()
    {

    return playerFirstName;
  25. Replies
    16
    Views
    3,283

    Char array problem.

    Hi guys,

    Having a problem returning a whole char array from a function. (Player name)

    For example, I have a player class, one of the attributes is char playerName[10].

    I have a public...
Results 1 to 25 of 33
Page 1 of 2 1 2