help with member function

Dec 6, 2013 at 10:18pm
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 << "**********"
          <<  "********"
          <<   "******"
          <<    "****"
          <<     "**"
          <<      "*"
}
Dec 6, 2013 at 11:16pm
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 Dec 6, 2013 at 11:17pm
Dec 6, 2013 at 11:40pm
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.
Dec 6, 2013 at 11:50pm
Hi @seanybarra,

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

Dec 6, 2013 at 11:50pm
Does the file cdie.cpp have #include <iostream> and using std::cout; ?
Topic archived. No new replies allowed.