我有一point堂课:
class Point
{
public int x;
public int y;
public Point(int x,int y)
{
this.x=x;
this.y=y;
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个map存储值:
Map<Point,Integer> map = new HashMap<Point,Integer>();
map.put(new point(1,1)) = 10;
Run Code Online (Sandbox Code Playgroud)
我想map通过一个明确的点来获取值:
map.get(new point(1,1));
Run Code Online (Sandbox Code Playgroud)
但它返回null。这可能是因为他们的参考不同。我想知道如何修复它,而不是使用二维数组。
当我同时声明时,vscode无法编译文件,并且出现错误日志:
> Executing task: C:\mingw64\bin\gcc.exe -g d:\CODES\C++\try\main.cpp -o d:\CODES\C++\try\main.exe <
C:\Users\16337\AppData\Local\Temp\ccqDR0fO.o: In function `__tcf_0':
C:/mingw64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
C:\Users\16337\AppData\Local\Temp\ccqDR0fO.o: In function `__static_initialization_and_destruction_0':
C:/mingw64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我的代码很简单:
#include <iostream>
#include <stdio.h>
int main()
{
printf("print something");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Dev-C ++可以正确编译该代码。
如果删除#include <iostream>,则可以正确编译。