-1

say you have a class coded like this:

class Monster
{
public:
    Monster(std::string& name, int hp, int acc, int xpReward
            int armor, const std::string& weaponName, 
            int Lowdamage, int highdamage);


     //insert methods
private:
     //data types


};

what is the Monster(.... line do, create objects for the monster class? Is this a constructor? Really want to know everything this thing does

nvoigt
  • 75,013
  • 26
  • 93
  • 142
Jcodin
  • 73
  • 5
  • 5
    Basic language points are best answered with a good [book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – chris Apr 09 '14 at 18:58
  • You cannot ask questions like that on this site, I guess. – cubuspl42 Apr 09 '14 at 19:01
  • @cubuspl42: you can ask and get answers, but they aren't good questions and they tend to get voted down or even closed. It's not a good question for a few reasons: it doesn't show any effort (looking up constructors in any C++ book would answer the question); it's very unlikely to be helpful to others (who else will wonder whether this particular function is or isn't a constructor, and find this question by search?); it has an unanswerable bit at the end ("everything this does"). None of that hurts the questioner, who has the answer. It wasn't mod-deleted like forbidden things (spam) are. – Steve Jessop Apr 09 '14 at 19:20
  • @SteveJessop well first of all not every has access to books, hint why the go to the internet. Second its not a complicated question. And the reason for the 'everything it does' is because sometimes when your asking a question your completely unaware of the other side of things – Jcodin Apr 09 '14 at 19:28
  • @Jcodin: Btw I don't think you're a bad person [and it probably wouldn't matter much to you if I did :-)] I just think this is a bad question for the site. However, you *cannot* learn C++ just by asking a sequence of basic questions on StackOverflow. It's just not possible. By all means go to the internet, but start with a tutorial. – Steve Jessop Apr 09 '14 at 19:39
  • I've got a tutorial and pretty good ones, but this one thing just needed a different perspective to understand the parts of a constructor, and the function is does – Jcodin Apr 09 '14 at 19:41

1 Answers1

0

It's the declaration of a parameterized constructor. Right now, it's just the declaration, it does nothing, you did not post the code that belongs to it.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Is it basically a declaration of a bunch of objects assigned to the class name a constructor is declared in? – Jcodin Apr 09 '14 at 19:29
  • What a constructor is and does is beyond the scope of this Q&A. I'd suggest you read a good book on the subject or find a good online tutorial. – nvoigt Apr 09 '14 at 19:35
  • okay @nvoigt I really fail to see how some people cannot grasp the idea that not everyone has access to books, that's why people move towards the internet to find the answers. I've looked online but the explanations don't give it to you clearly. – Jcodin Apr 09 '14 at 19:38
  • @Jcodin to be honest, I really fail to see how you can have a computer and internet access, but no public library where you live. But even if you don't have a public library, you can still put "C++ tutorial constructor" into google and read that page. Because there is dozens of pages that already explain the basics, there is no need to cite the same info here again and again. – nvoigt Apr 09 '14 at 19:48