#include"class.h"
void Shape::set_values(int a, int b){
length=a;
width=b;
}
void Shape::print_area(){
cout << "The area is " << length*width << endl;
}
class.h
1 2 3 4 5 6
class Shape {
int length, width;
public:
void set_values(int,int);
void print_area();
};
I get the following compiler errors.
1 2 3 4
In file included from source.cpp:5:
class.cpp: In member function ‘void Shape::print_area()’:
class.cpp:9: error: ‘cout’ was not declared in this scope
class.cpp:9: error: ‘endl’ was not declared in this scope
I thought that if I included iostream in source.cpp I could use its member functions in any further linked file. If I include iostream in class.cpp I get the same compiler errors. I've done some reading on linking but haven't found an explanation that makes clear sense to me.