小编Ren*_*Zou的帖子

如何在JAVA中交换两个arraylist?

有两个ArrayList例如list1 = {1,2,3} 和list2 = {7,6,4,2}如何交换这两个列表.结果将是list1 = {7,6,4,2},list2 = {1,2,3} 我可以像这样实现:

public void swapList(ArrayList<Integer> list1, ArrayList<Integer> list2){
    ArrayList<Integer> tmpList = list1;
    list1 = list2;
    list2 = tmpList;
}
Run Code Online (Sandbox Code Playgroud)

java arraylist

4
推荐指数
1
解决办法
7181
查看次数

编译器报告:错误:'using'之前的预期unqualified-id

我有两个文件,homework1.cc和homework1.h.

顶部homework1.cc是

#include <iostream>
#include <fstream>
#include <cstring>
#include <GL/glut.h>
#include "homework1.h"

using namespace std;
Run Code Online (Sandbox Code Playgroud)

而顶部homework1.h是

#ifndef _rt_H
#define _rt_H

#include <cmath>
#include <vector>
#include <list>
#include <GL/glut.h>

using namespace std;
Run Code Online (Sandbox Code Playgroud)

这是我用list的地方homework1.h

class surTriangle
{
    float x;
    float y;
    float z;
    list <int> surTriangles;

    bool compareVertex(Vector3f anotherVec)
    {
        if(anotherVec[0] == x && anotherVec[1] == y && anotherVec[2] == z)
            return true;
        return false;
    }

} 
Run Code Online (Sandbox Code Playgroud)

当我尝试编译时homework.cc,编译器报告

homework1.cc:8:错误:在'使用'之前预期的unqualified-id …

c++

2
推荐指数
1
解决办法
4311
查看次数

标签 统计

arraylist ×1

c++ ×1

java ×1