~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

the proprietary content.

PS: Welcome back Mr. Darren :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Our error handling routines work around many ERRORS

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Feeling it - Blink 182

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There is no portable way of changing text color in C. It is highly a compiler dependent or OS dependent feature. If you are using Turbo compiler you can use the console I/O functions cprintf() and cputs() for color output.

#include <conio.h>
      int main()
      {
          textcolor(BLUE);
          cprintf("I'm blue.");
          return 0 ;
      }
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thanks for the help and he links thatwas good info. Merry Christmas

AH the Christmas spirit...Merry Christmas to you too my good friend.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

you should learn to write better code then :p (couldn't resist)

:( :D

Our error-handling ROUTINES work with many bugs

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Holidays are fun

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can drop the inheritance and put in the Circle class a private data member center of type point. This way you would be able to use all the methods of the Point class on the center of the circle while keeping the design of Circle class intact.

class Circle:public Point3d
{
    // all the members
} ;

// with composition
class Circle
{
    Point3d* pt ;   // or Point3d pt, your call
  
   // other circle members 
} ;

Also read this and this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

//I need to change this program from using inheritance to using composition.
//Could someone please show me how? I have two other programs that I can surely do myself.
//I'm really in search of a sample.

I don't see any inheritance in your program, just a single point class. And I think that for inheritance you need to have more than one class ;)

Have you posted the entire code or is this just a part of it ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
  • I would like to teach a good lesson to all those suffering from sarcastocommenta and who intentionally or unintentionally end up hurting other people.
  • I don't belive in gods, saviours, etc..
  • At the end of the day, I end up hating the world a bit more.
  • Normally during my free time I comtemplate.
  • I don't keep track of the world around me, as a way of expressing that I don't give a damn..:D
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Our tech ALGORITHMS work with many bugs.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Harder than any other thing in this world is to make someone happy.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Because when you are reading data from the file, it is read in the form of string and in your case, its C string.

The thing about C strings is that other than the characters it holds, it reserves a extra space at the end of the character array for the null character ('\0') which signifies the end of the C style or character array style string.

So when you are reading "AAAA" in your case, its actually is :

AAAA'\0'

As you can see the last character is the null character which is automatically appended at the end of character arrays so that they can be treated as strings. This null character even doesn't show up when you query the length of the string using strlen( ) and hence is a common mistake made by beginners to assume that C strings only require the size equivalent to the number of characters they contain.

So in your previous code, you were using an array of size 4 which caused the null character to be copied to a location which doesn't belong to you and it overwrote the memory which you don't own. This normally leads to what is known as "Segmentation Error" i.e. modifying or touching memory which doesn't belong to you.

Hence changing the size from 4 to 5 caused your code to function correctly. Also consider changing from three sscanf( ) statements to a single fgets( ) and sscanf( ) which leads to a …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Forums like Daniweb, CProgramming etc. and email posts just don't go hand in hand. It beats the very idea of forums.

If you love email posts that much you can try suscribing to Google groups wherein you receive the notifications and the post contents through emails.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hi Mathew, happygeek here - 6'2", bald, pale and interesting

Welcome to Daniweb buddy and for the actual description of Mr. Happygeek just take a look at his avatar.....:P

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Welcome to Daniweb :D

You seem to be really famous among the people here...;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a ticked record

I put in a hat.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

True -> False

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

laws to do

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OUR tech toys work with many excuses

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Evening is when I reach my house after work.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your peons work with no PERKS.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Bullies are what we all are, in one way or the other. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

One more mistake that I can see in your code is in your constructor:

Key(char* data) { this->data = new char[strlen(data)];

I think you are not leaving off enough space for the null character which is present at the end of C style strings.

For eg. if the string passed is "a+b+c", length is 6 since there is a null character at the end. And your constructor is invoked with something like:
this->data = new char[5] ; // this is wrong

So change that line to

Key(char* data) { this->data = new char[strlen(data) + 1 ];

Make this change, then repost along with a sample run of your program, along with input provided by you, output of the program and the expected output. That way it would be simpler to help you out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

All your problems are solely related to the findKey( ) method. You have overloaded the findKey( ) to work with three different types of parameter sets but using it in wrong manner.

See the comments marked in red by me in your code.

Key key; // key holds the data
BST_Node* left; // ptr to left subtree
BST_Node* right; // ptr to right subtree
 
public:
// Managers
BST_Node(); //default constructor
BST_Node(Key key); // Construct given key-data
BST_Node(BST_Node& node); // Copy Constructor
~BST_Node(); // Destruct node
// Operators
BST_Node& operator= (BST_Node& node); // Assignment
// Accessors
Key getKey() {return key;} // get Key Data
BST_Node*& getLeft() {return left;} // get root of left subtree
BST_Node*& getRight() {return right;} // get root of right subtree
};
BST_Node::BST_Node() {
left = NULL;
right = NULL;
}
BST_Node::BST_Node(Key key) { // Construct given key-data
this->key = key;
left = NULL;
right = NULL;
}
BST_Node::BST_Node(BST_Node& node) { // Copy Constructor
this->key = node.key;
left = NULL;
right = NULL;
}
BST_Node::~BST_Node(){ // Destruct node
// BST will handle deletions
//delete left;
//delete right;
}
// Operators
BST_Node& BST_Node::operator= (BST_Node& node) { // Assignment
this->key = node.key;
left = node.left;
right = node.right;
 
return *this;
}
 
/*********************************************************************/
class BST {
private:
BST_Node* root; // root of tree
int size; // number of elements in tree
// Mutators - called by public methods
bool insert(BST_Node* &subRoot, BST_Node* &node); // insert to subtree (recursive)
void preOrder(BST_Node* subRoot); // preOrder-Traversal of tree (recursive)
void inOrder(BST_Node* subRoot); …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

YOUR peons work on any resources

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

World is not a child that can be bullied by you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

be distributed openly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

druggy -> sober

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a shrimp cocktail

I put in an octopus

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

are proprietary content

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

needle -> syringe

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My schools work with any RESOURCES

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You become enlightened

I put in a tree

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The only problem with being right all of the time is that people really let you have it when you make a mistake.

and the good thing about being err...rough is that they all support you when you don't get it right for the fear you might fly in fury mode...;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

rip it apart.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

thorns -> pricking

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

MANY schools work with any chidren

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get completely charged.

I put in a Television set

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Exist for the good of everyone.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No PROGRAMMERS work without any coffee

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

grasshopper -> green

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

each and every

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Far away place I have come from, hence I can achieve such a feat.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a deck of playing cards

I put in some strings

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Friendly BOSSES work without any coffee.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Geek -> creek

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get to meet with Pythagorus.

I put in the color black.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

people around us.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What I meant was that since these names were written on the page titled "Softwares made in C++" , he must have obvioulsy implied that C++ was used to make WinXP.