www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Is this a DMC Bug?

↑ ↓ ← 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
→ 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
→ 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
→ "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