I'm still really green at this, but I've been working at this for 2 hours now and I'm stuck. Can someone help me? I'll post the code first, then the error underneath.
thanks everyone!
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
class Resource {
public:
string Name_;
int Food_;
int Production_;
int Commerce_;
string ReqImprovement_;
public:
Resource( string myName, int myFood, int myProduction, int myCommerce, string myImprovement )
: Name_(myName), Food_(myFood), Production_( myProduction),
Commerce_( myCommerce), ReqImprovement_(myImprovement){};
Resource( const Resource & myResource );
const void setResource(string myName, int myFood, int myProduction, int myCommerce, string myImprovement);
};
const void Resource::setResource(string myName, int myFood, int myProduction, int myCommerce, string myImprovement){
Name_ = myName;
Food_ = myFood;
Production_ = myProduction;
Commerce_ = myCommerce;
ReqImprovement_ = myImprovement;
}
int main() {
vector<Resource> vResource; //("Name", food, prod, comm, "Required")
//these two lines work.
Resource tempResource( "Aluminum", 0,1,0, "Mine");
vResource.push_back(tempResource);
//this line doesn't
vResource.push_back( Resource( new Resource("Wheat", 1,0,0, "Farm") ) );
return 0;
}
the error
======
linux:~/Desktop/project3 # g++ civ_v2.cpp
civ_v2.cpp: In function `int main()':
civ_v2.cpp:193: error: no matching function for call to `Resource::Resource(
Resource*)'
civ_v2.cpp:91: error: candidates are: Resource::Resource(const Resource&)
civ_v2.cpp:89: error:
Resource::Resource(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, int, int, int, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >)