Dev cpp gives me the error
18 C:\Dev-Cpp\Untitled1.cpp request for member setStats' inplant1', 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;
}

>>Plants plant1();

When declaring an object do not include the (). Its just Plants plant1;

>>Plants plant1();

When declaring an object do not include the (). Its just Plants plant1;

Tried it but gives me a new error. thanks though

You were right. i fixed it a little bit more but now it gives me

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe Untitled1.o plants.o  -o "Project1.exe" -L"C:/Dev-Cpp/lib"  

Untitled1.o(.text+0x182):Untitled1.cpp: undefined reference to `Plants::Plants()'
collect2: ld returned 1 exit status

make.exe: *** [Project1.exe] Error 1

Execution terminated

main code is

#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;

 }


header file

#include <string>
using std::string;

class Plants
{
    public:

    void setStats(string);
    int getSize();
    int getAge();
    string getName();       

private:
 string kind;
 string name;
 int age;
 int size;
};


and .cpp file

// Class automatically generated by Dev-C++ New Class wizard
#include <iostream>

#include <cstdlib>
using std::rand;

#include "Plants.h"


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;
}

You are trying to use a default constructor without having a default constructor defined.

EDIT:
Part of your issue before was that you had an "overloaded" constructor but no default constructor, which normally isn't a good thing. It seems that it still thinks there isn't one.
/EDIT:


I suggest you study constructors and destructors a little more...

Thanks. I guess I should. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.