help with member function

im trying to get a memeber function to perform a cout statement but everyt time i compile it tells me that in this member function that "cout" was never declared in this scope I've tried numerous approaches but none have worked can some one help me please.

1
2
3
4
5
6
7
8
9
  void CDie::Draw(void) const
{
     cout << "**********"
          <<  "********"
          <<   "******"
          <<    "****"
          <<     "**"
          <<      "*"
}
I assume that you have #include <iostream> somewhere already. All standard library classes are implemented in the std namespace. You can either put using namespace std; after your #include directives, or write std::cout. The latter is better practice, because it avoids mixing in all the std namespace declarations with your own.
Last edited on
should have mentioned this but this function is in a file called cdie.cpp, the main function is in main.cpp, and the head file is where the class is located in cdie.h. everytime i intiate g++ -c main.cpp cdie.cpp it gives me that error message all the files include the header file and the directives are in the main.cpp as well as namespace std.
Hi @seanybarra,

first off i
see that is
missing
;
1
2
3
4
5
6
7
8
9
void CDie::Draw(void) const
{
     cout << "**********"
          <<  "********"
          <<   "******"
          <<    "****"
          <<     "**"
          <<      "*"; ///<---------
}

Does the file cdie.cpp have #include <iostream> and using std::cout; ?
Topic archived. No new replies allowed.