www.digitalmars.com         C & C++   DMDScript  

c++ - Is this a DMC Bug?

reply Tony P. <kd1s aol.com writes:
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?
Jan 05 2004
next sibling parent Tony P. <Tony_member pathlink.com> writes:
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?
Jan 05 2004
prev sibling next sibling parent arjan someplace.somewhere writes:
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
Jan 05 2004
prev sibling parent "KTC" <me here.com> writes:
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!!!

:)
Jan 06 2004