#Basic C++ Homework Help
14 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Code E0392: member function "Barn::feedChickens" may not be redeclared outside its class
!f
Barn.h
#pragma once
#include <iostream>
#include <vector>
#include "Animal.h"
#include "Chicken.h"
#include "Cow.h"
#include "Pig.h"
using namespace std;
class Barn {
private:
vector<Chicken> coop;
vector<Pig> pigPen;
vector<Cow> cowPen;
public:
Barn();
void feedChickens();
void feedPigs();
void feedCows();
};
!f
Barn.cpp
#include "Barn.h"
// Constructor
Barn::Barn() {
// Chicken- Hen Solo
for (int i = 0; i < 1; i++) {
string name = "Hen Solo";
Chicken c(name, 5);
coop.push_back(c);
}
// Cow- Daisy Daisy Daisy
for (int i = 0; i < 1; i++) {
string name = "Daisy Daisy Daisy";
Cow c(name, 1411);
cowPen.push_back(c);
}
// Pig- Hammy
for (int i = 0; i < 1; i++) {
string name = "Hammy";
Pig c(name, 280);
pigPen.push_back(c);
}
// Feed all chickens
void Barn::feedChickens() {
for (Chicken& chicken : coop) {
chicken.eat();
}
}
// Feed all cows
void Barn::feedCows() {
for (Cow& cow : cowPen) {
cow.eat();
}
}
// Feed all pigs
void Barn::feedPigs() {
for (Pig& pig : pigPen) {
pig.eat();
}
}
}
the very last } should be moved to just before void Barn::feedChickens()