I'm unable to get my code to run, and the internet doesn't seem to know why. I'm not sure what I need to let you know, but I am using CLion if that helps.
This is my plant.h file:
#ifndef COURSEWORK_PLANT_H
#define COURSEWORK_PLANT_H
using namespace std;
class Plant {
public:
void addGrowth();
int getSize();
string getName();
Plant(string x, int y);
private:
string plantName;
int plantSize;
};
#endif //COURSEWORK_PLANT_H
This is my plant.cpp file:
#include <iostream>
#include "plant.h"
using namespace std;
void Plant::addGrowth(int x) {
plantSize += x;
cout << "You have added " << x << " leaves to your plant. Well done!";
}
int Plant::getSize() {
return Plant::plantSize;
}
string Plant::getName() {
return Plant::plantName;
}
This is my main.cpp file:
#include <iostream>
#include "plant.h"
using namespace std;
int main() {
Plant myPlant("Bugg", 2);
return 0;
}
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.21)
project(Coursework)
set(CMAKE_CXX_STANDARD 14)
add_executable(Coursework main.cpp plant.h plant.cpp)
Thank you in advance for any help!