Thread overview
Is this a DMC Bug?
Jan 06, 2004
Tony P. <kd1s
Jan 06, 2004
Tony P.
Jan 06, 2004
arjan
Jan 06, 2004
KTC
January 06, 2004
Ok - I recently downloaded DMC as I needed a C++ compiler. Been using the Teach Yourself C++ Programming in 21 days book. In any case, I created this source file:

#include <iostream.h>		// for cout

class Cat			// begin declaration of the class
{
public:			// begin public section
int GetAge();		// accessor function
void SetAge (int age);	// accessor function
void meow();		// general function
private:
int itsAge;
};

int Cat::GetAge()
{
return itsAge;
}

void Cat::SetAge(int age)
{
itsAge = Age;
}

void Cat::Meow()
{
cout << "Meow!\n";
}

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

When I attempt to compile I get:

I:\dm\bin>dmc ..\src\tycc6-3.cpp
itsAge = Age;
^
.\src\tycc6-3.cpp(23) : Error: undefined identifier 'Age'
{
^
.\src\tycc6-3.cpp(27) : Error: 'Meow' is not a member of struct 'Cat'
Frisky.Meow();
^
.\src\tycc6-3.cpp(35) : Error: 'Meow' is not a member of struct 'Cat'
Frisky.Meow();
^
.\src\tycc6-3.cpp(38) : Error: 'Meow' is not a member of struct 'Cat'
--- errorlevel 1

This is right out of the book. What gives?



January 06, 2004
Disregard. I found the problems. Seems that the Age vs. age thing got me, and Meow vs. meow.

Grrrrr..... case sensitivity. The bane of my existence. :)

In article <btdn3g$2e6j$1@digitaldaemon.com>, Tony P. <kd1s@aol.com says...
>
>Ok - I recently downloaded DMC as I needed a C++ compiler. Been using the Teach Yourself C++ Programming in 21 days book. In any case, I created this source file:
>
>#include <iostream.h>		// for cout
>
>class Cat			// begin declaration of the class
>{
>public:			// begin public section
>int GetAge();		// accessor function
>void SetAge (int age);	// accessor function
>void meow();		// general function
>private:
>int itsAge;
>};
>
>int Cat::GetAge()
>{
>return itsAge;
>}
>
>void Cat::SetAge(int age)
>{
>itsAge = Age;
>}
>
>void Cat::Meow()
>{
>cout << "Meow!\n";
>}
>
>void main()
>{
>Cat Frisky;
>Frisky.SetAge(5);
>Frisky.Meow();
>cout << "Frisky is a cat who is ";
>cout << Frisky.GetAge() << " years old.\n";
>Frisky.Meow();
>}
>
>When I attempt to compile I get:
>
>I:\dm\bin>dmc ..\src\tycc6-3.cpp
>itsAge = Age;
>^
>.\src\tycc6-3.cpp(23) : Error: undefined identifier 'Age'
>{
>^
>.\src\tycc6-3.cpp(27) : Error: 'Meow' is not a member of struct 'Cat'
>Frisky.Meow();
>^
>.\src\tycc6-3.cpp(35) : Error: 'Meow' is not a member of struct 'Cat'
>Frisky.Meow();
>^
>.\src\tycc6-3.cpp(38) : Error: 'Meow' is not a member of struct 'Cat'
>--- errorlevel 1
>
>This is right out of the book. What gives?
>
>
>


January 06, 2004
In article <btdn3g$2e6j$1@digitaldaemon.com>, Tony P. <kd1s@aol.com says... ..
>
>void Cat::SetAge(int age)
>{
>itsAge = Age;
>}
..
>When I attempt to compile I get:
>
>I:\dm\bin>dmc ..\src\tycc6-3.cpp
>itsAge = Age;
>^
>.\src\tycc6-3.cpp(23) : Error: undefined identifier 'Age'
>

'Age' is not the same as 'age'

void Cat :: SetAge ( int  age )
{
itsAge = age;
}

Change the case of Age to age.

Good Luck
Arjan


January 06, 2004
Ah yes, silly little things like that can be annonying :D

Btw, you must have an rather old copy of the book coz the book should have used (indeed the copy I've got from copy of years ago does)

#include <iostream>
std::cout << .....
int main()          <---- int not void!!!

:)