How do I declare and initialize a 2d int vector in C++?

前端 未结 3 1893
时光说笑
时光说笑 2020-12-30 15:02

I\'m trying to do something like:

#include 
#include 
#include 

class Clickomania
{
    public:
        Clickoman         


        
3条回答
  •  不知归路
    2020-12-30 15:48

    Compiling your code with g++, the error I get is that neither srand() nor rand() were declared. I had to add #include for the code to compile. But once I did that, it worked just fine. So, I'd say that other than adding that include statement, your code is fine. You're initializing the vector correctly.

    Perhaps the code you have doesn't quite match what you posted? I would assume that if your actual code didn't include cstdlib, that you would have quickly understood that that was the problem rather than something with vector. So, if your code doesn't quite match what you posted, maybe that's the problem. If not, what compiler are you using?

提交回复
热议问题