c++ - cout is not a member of std -
i'm practicing using mulitple files , header files etc. have project takes 2 numbers , adds them. pretty simple.
here files:
main.cpp
#include <iostream> #include "add.h" int main() { int x = readnumber(); int y = readnumber(); writeanswer(x + y); return(0); } io.cpp
int readnumber() { int x; std::cout << "number: "; std::cin >> x; return x; } void writeanswer(int x) { std::cout << "answer: "; std::cout << x; } add.h
#ifndef add_h_included #define add_h_included int readnumber(); void writeanswer(int x); #endif // #ifndef add_h_included the error showing in io.cpp. exact errors are:
http://gyazo.com/117f407f4717ad4472f52b57b628c514.png
does have idea why may happening? thanks.
edit: made small project yesterday same amount of files (2 .cpp , 1.h) , didn't include iostream header in other .cpp , still compiled , ran fine.
add #include <iostream> start of io.cpp too.
Comments
Post a Comment