开发者

How to load Multidimensional array values into vector?

This is part of the code (header and the main part):

#include <iostream>
#include <sstream>
#include <string>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <glut.h>
#include <RassHost.h>
#include <api\iomap.h>
#include <api\iotrans.h>
#include <api\cgeometry.h>
#include <vector>

using namespace std;

int main()
{
    cout << "Enter IP: " << endl;
开发者_如何学运维    getline(cin, server_ip);

    enum(KEY_L = 'A', KEY_R = 'D', KEY_RUN = 'WW', KEY_JUMP='SPACE');

    typedef OBJECT_3D_SYS_TYPES_NUM OBJECT3D_RCN_TYPE;

    OBJECT3D_RCN_TYPE _psyObjects[][] = getPsyhicsPartObjects();

    vector<OBJECT3D_RCN_TYPE> _objects;

    //I would like to load _psyObjects[][] into vector<OBJECT3D_RCN_TYPE> _objects;

    Server::StartGame(Server::getIP(), 8888, "-r run", false);

    system("pause");
    return 0;
}

Is it possible to copy _psyObjects values into vector<OBJECT3D_RCN_TYPE>?

I want to control the multidimensional array with vector api, if it is possible.

Thanks!


You'll need to create a vector of vectors:

vector< vector<OBJECT3D_RCN_TYPE> > _objects;

Then just fill it like a normal vector.

I'd post more code, but you need to know the dimensions of the array, and I can't see those from the code.


You could also use a Boost::multi_array. It's api is like std::vector's, but possibly similar enough to meet your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜