Why I cannot cout a string?
You need to include
#include <string>
#include <iostream>
There are several problems with your code:
WordList
is not defined anywhere. You should define it before you use it.- You can't just write code outside a function like this. You need to put it in a function.
- You need to
#include <string>
before you can use the string class and iostream before you usecout
orendl
. string
,cout
andendl
live in thestd
namespace, so you can not access them without prefixing them withstd::
unless you use theusing
directive to bring them into scope first.
You need to reference the cout's namespace std
somehow. For instance, insert
using std::cout;
using std::endl;
on top of your function definition, or the file.