Nathaniel10 34 Junior Poster

Hello All,

Thank you for responding to my question. I had to set it aside for a few weeks because oher things in life intervened. I am learning program part-time. This is not ideal becuase you really need to be immersed in it, but my current circumstances do not permit a heavy time committment.

I recently found a solution to my problem. My old computer had the php.ini file set to suppress error reporting. XAMMP has a default of setting for error reporting to include E_NOTICE. My code was wrong, or at least weaker than ideal, but PHP didn't report the weaknesses. I was using variables before verifying that they existed.

In XAMMP the weaknesses are being reported. As it is better practice to report errors, I needed to improve my code. I found two receommendations; one using isset() and the other using array_key_exists(). I chose the array method. So my prior code of:

$phpvariable = $_POST['htmlformvariable'];

is now:

$phpvariable = array_key_exists('htmlformvariable', $_POST) ? $_POST['htmlformvariable'] : NULL;

And I have no more notices.

I also discovered there is a lot of misinformation and misunderstanding in the cyberspace regarding PHP best practices. One must be very persistent and diligent in order to find what one needs.

Nathaniel10 34 Junior Poster

@cereal, you are correct.

It seems that in nesting the functions, I commented out a needed line. That caused the error in the result. With the that line restored, the nested min/max functions work fine.

Sorry for the false alarm.

Corollary: Do not code when you are tired.

Nathaniel10 34 Junior Poster

WOW! Not be too harsh, but doesn't your professor/college teach about pseudo code?
I am just learning C++, but my textbook stresses that the most important part of programming is organizing your thoughts and ideas. This is done by writing pseudo code and a grammar BEFORE writing the program code itself. Put the horse before the cart.

Ancient Dragon commented: good point :) +33
Nathaniel10 34 Junior Poster

I am learning C++ from the Stroustrup book "Programming Principles and Practice". I have been doing the exercises in each chapter. I have gotten stuck on chapter 6. I understand the concepts of classes, constructors, functions, and 'throw and catch' error handling, but seemingly not well enough to actually write a program with these elements that compiles and runs. I have written a program for exercise 10 in chapter 6 that runs almost correctly.

It is not a pretty program and the error exception for non-integer inputs causes the program to crash with a message relating to error exception #3 instead of my intended #4. I don't know how to put all the error exceptions into the same class. Thank you in advance for your help!

N.B. You will have to change the header line if you want to run this program. The header in the program is the one Stroustrup instructs us to download from his site

#include "../../std_lib_facilities.h"

class myexception1: public exception    // Classes for handling errors.
{
  virtual const char* what() const throw()
  {
    return "The set and subset sizes must be greater than 0.\n";
  }
} myex1;

class myexception2: public exception
{
  virtual const char* what() const throw()
  {
    return "The set size must be greater than the subset size.\n";
  }
} myex2;

class myexception3: public exception
{
  virtual const char* what() const throw()
  {
    return "Either a 'c' for combination or a 'p' for permutation must be indicated.\n";
  }
} myex3;

class …
dusktreader commented: I am impressed by your ambition to self-teach c++. Nice code +1