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
}

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

Excuse me? I do not understand what you mean at all...

#include <iostream.h>

Try this instead:

#include <iostream>

Think WaltP just posted wrong!

Think WaltP just posted wrong!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.