Reputation: 27
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class TaroGrid{
public:
int getNumber(vector<string> grid)
{
int n = grid.size(), max = 0, count = 1;
for (int j = 0; j < n; j++)
{
for (int i = 1; i < n; i++)
{
if (grid[i][j] == grid[i - 1][j]) count++;
else count = 1;
if (count > max) max = count;
}
}
return max;
};
};
int main()
{
TaroGrid test;
vector<string> cool;
int t = test.getNumber(cool);
cout << "The largest number of cells Taro can choose is: " << t <<endl;
return 0;
}
Your code did not compile:
errors linking:
TaroGrid-stub.o:In function `main':
TaroGrid-stub.cc:(.text.startup+0x0): multiple definition of `main'
TaroGrid.o:
TaroGrid-stub.cc:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status
Upvotes: 1
Views: 117
Reputation: 283891
You've compiled TaroGrid-stub.cc
twice, naming the object files differently TaroGrid-stub.o
and TaroGrid.o
. These two objects are mostly identical (they might be different versions of the same code). They definitely both have a main
function.
Then you passed both objects to the linker, which can't decide which is the real main
.
There are a couple possible solutions.
*.o
, but actually name the specific object files you intend to use.Upvotes: 2