Course Catalog
Curriculum Guides
  .NET
  Java/J2EE
  XML
Downloads
Buy Courseware
Customization
News
Authors
Technical Library
FAQ
About Object Innovations
Opportunities
Contact Us
Home

 

 

   
www.objectinnovations.com
info@objectinnovations.com
877-558-7246 (toll free)  
781-466-8012  


Details about bugs in example programs in
.NET Architecture and Programming Using Visual C++



Customer id does not increment properly in some of the example program
There is bug that causes the customer id to not increment properly in some of the example programs. This bug is found in each of the following source files:

C:\OI\NetCpp\Chap06\Components\Customer\Customer.h
C:\OI\NetCpp\Chap07\CaseStudy\Customer\Customer.h
C:\OI\NetCpp\Chap08\Asynch\Customer\Customer.h
C:\OI\NetCpp\Chap08\Dynamic\Customer\Customer.h
C:\OI\NetCpp\Chap08\Reflection\Customer\Customer.h

The bug is that the following member in the Customer class should be static, and initialized to 1:

int nextCustId;

This should be changed to:

static int nextCustId = 1;

Also, the three Customer class constructors should not initialize the nextCustId to 1. Thus, the following:

Customer(String *first, String *last, String *email)
: nextCustId(1)
{
  CustomerId = nextCustId++;
  FirstName = first;
  LastName = last;
  EmailAddress = email;
}
Customer() : nextCustId(1)
{
}
Customer(int id) : nextCustId(1)
{
  CustomerId = id;
  FirstName = "";
  LastName = "";
  EmailAddress = "";
}

Should be changed to:

Customer(String *first, String *last, String *email)
{
  CustomerId = nextCustId++;
  FirstName = first;
  LastName = last;
  EmailAddress = email;
}
Customer()
{
}
Customer(int id)
{
  CustomerId = id;
  FirstName = "";
  LastName = "";
  EmailAddress = "";
}