Dev cpp gives me the error
18 C:\Dev-Cpp\Untitled1.cpp request for member setStats' in
plant1', which is of non-class type `Plants ()()'
And the same for line 19. Please someone tell me what's wrong. I'm a noob at c++. Thanks in advance.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using std::string;
using std::getline;
#include "Plants.h"
int main()
{
string kind;
Plants plant1();
cout<<"Enter plant kind"<<endl;
cin >> kind;
plant1.setStats(kind);
cout << plant1.getAge() << " " << plant1.getSize() << " " << plant1.getName() << endl;
cin.get()
}
Header
#include <string>
using std::string;
class Plants
{
public:
Plants(string);
void setStats(string);
int getSize();
int getAge();
string getName();
private:
string kind;
string name;
int age;
int size;
};
class cpp
#include <iostream>
#include <cstdlib>
using std::rand;
#include "Plants.h"
// class constructor
Plants::Plants()
{
}
void Plants::setStats(string kind)
{
name = kind;
size = 1 + rand()%10;
age = 0;
}
int Plants::getSize()
{
return size;
}
int Plants::getAge()
{
return age;
}
string Plants::getName()
{
return name;
}