whats wrong with my code it wont compile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "stdafx.h"
#include <iostream>

   class Cat                
   {
    public:                
    int itsAge;
    int itsWeight;
  };


void main()
  {
     Cat Frisky;
     Frisky.itsAge = 5;    
     cout << "Frisky is a cat who is ";
     cout << Frisky.itsAge << " years old.\n";
 }


i know i shouldent get dependent on forums but i need help with this i have no idea.

compiler error code
------ Build started: Project: project freedom, Configuration: Debug Win32 ------
project freedom.cpp
project freedom.cpp(18): error C2065: 'cout' : undeclared identifier
project freedom.cpp(19): error C2065: 'cout' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

how is cout an undeclared identifier!!!
Put using namespace std;, using std::cout or std::cout << "string";
Also, don't use void main(), use int main() and return 0 at the end.
cout is part of the std namespace, so either:

(a) put std:: in front of cout, or

(b) put using namespace std; at some point before main(), or you could put it in main() if you know that only main() will be using symbols from std.

Also, you should use int main() instead of void main(). Remember to put return 0; at the end of main()
ahhh IM SUCH AN IDOIT i cant believe i didnt see that well lesson learned anyway thank you all
Topic archived. No new replies allowed.