Check out example codes for "cout does not name a type". It will help you in understanding the concepts better.

Code Example 1

//Statements in C++ need to be inside of a function
int main(){
	std::cout << "Hello World" << std::endl;
    //Works because we are inside of a function
}
std::cout << "Hello World" << std::endl;
//Doesn't work because we are not inside of a function

Learn ReactJs, React Native from akashmittal.com