Hi everyone, just learning c++ cannot for the life of me work out what is wrong with this code..?

All I am getting is cout , undeclared identifier.

Anyone help?

#include <iostream.h>
#include "stdafx.h"

using namespace std;
//declare stripped down class SimpleCat
     class SimpleCat
     {
public:
            SimpleCat(); //SimpleCat contstructor
             ~SimpleCat(); //SimpleCat destructor
     private:
             int itsAge;
        

        SimpleCat::SimpleCat()
        {
               cout << "Constructor called.\n";
               itsAge = 1;
        }

        SimpleCat::~SimpleCat()
        {
               cout << "Destructor called.\n";
		}
	 };
int main()
        {
               cout << "SimpleCat Frisky...\n";
               SimpleCat Frisky; //Frisky is created on the stack and calls constructor
               cout << "SimpleCat *pRags = new SimpleCat...\n";
               SimpleCat * pRags = new SimpleCat; //SimpleCat pointed to by pRags
               cout << "delete pRags...\n"; 
               delete pRags; //delete is called on pRags – destructor is called
               cout << "Exiting, watch Frisky go...\n";
        return 0; //when the function ends Frisky goes out of scope
}

Edited 5 Years Ago by james6754: n/a

You forgot the ; on line 6.
The IF in line 8 cannot be in all capital letters.
And you misspelled PRINTF

Think WaltP just posted wrong!

No, he didn't post the code until after I saw his first and only post at that time.

This article has been dead for over six months. Start a new discussion instead.