For the following class I wanted to make a vector with 10 Ship() objects
However this yields the following compilation error invalid conversion from 'int' to 'const char*' [-fpermissive]
( If I omit the vector line it compiles just fine)
I did a little search and could not find an answer.
class Ship
{
protected:
std::string name;
public:
Ship(std::string name="Ship")
{
std::ostringstream tmp;
std::string temp;
tmp << name << ++id;
name = tmp.str();
}
};
Vector Declaration in main()
#include <iostream>
#include <vector>
#include <string>
#include "Ship.h"
using std::cout;
using std::endl;
using std::vector;
int main()
{
vector<Ship> Shipyard; //10% of map dimension is number of ships
Shipyard.push_back(Ship(10)); //push_back(Ship(),10); doesn't work also
}