error: expected constructor, destructor, or type conversion before '=' token

I'm trying to compile this function and the compiler is giving me: "error: expected constructor, destructor, or type conversion before '=' token"
for line 4
Growthrate.cpp
1
2
3
4
5
//int growthrate( death_rate, growth_rate)

//float growth;
growth = birth_rate/100 - death_rate/100;
return growth;

my header file
1
2
3
4
5
6
7
#ifndef POP_H_INCLUDED
#define POP_H_INCLUDED

int growthrate(int death_rate,int growth_rate);
int estimatedpopulation(int pop,int growth, int year);

#endif // POP_H_INCLUDED 
Last edited on
Is that all your CPP file contains?

Your CPP file needs to either contain methods (functions) or class implementation; with the header file containing the definition (prototypes).

For example:
MyFile.h
1
2
3
4
5
6
#ifndef MYFILE_H
#define MYFILE_H

int addNumbers(int A, int B);
int subtractNumbers(int A, int B);
#endif 


MyFile.cpp
1
2
3
4
5
6
7
int addNumbers(int A, int B) {
 return A + B;
}

int subtractNumbers(int A, int B) {
 return A - B;
}


I suggest you read http://www.cplusplus.com/doc/tutorial/functions/ and part 2
Topic archived. No new replies allowed.