the proprietary content.
PS: Welcome back Mr. Darren :D
the proprietary content.
PS: Welcome back Mr. Darren :D
Our error handling routines work around many ERRORS
Feeling it - Blink 182
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 ;
}
Thanks for the help and he links thatwas good info. Merry Christmas
AH the Christmas spirit...Merry Christmas to you too my good friend.
you should learn to write better code then :p (couldn't resist)
:( :D
Our error-handling ROUTINES work with many bugs
Holidays are fun
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
} ;
//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 ?
Our tech ALGORITHMS work with many bugs.
Harder than any other thing in this world is to make someone happy.
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 …
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.
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
Welcome to Daniweb :D
You seem to be really famous among the people here...;)
You get a ticked record
I put in a hat.
True -> False
laws to do
OUR tech toys work with many excuses
Evening is when I reach my house after work.
Your peons work with no PERKS.
Bullies are what we all are, in one way or the other. ;)
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.
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); …
YOUR peons work on any resources
World is not a child that can be bullied by you.
be distributed openly.
druggy -> sober
You get a shrimp cocktail
I put in an octopus
are proprietary content
needle -> syringe
My schools work with any RESOURCES
You become enlightened
I put in a tree
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...;)
rip it apart.
thorns -> pricking
MANY schools work with any chidren
You get completely charged.
I put in a Television set
Exist for the good of everyone.
No PROGRAMMERS work without any coffee
grasshopper -> green
each and every
Far away place I have come from, hence I can achieve such a feat.
You get a deck of playing cards
I put in some strings
Friendly BOSSES work without any coffee.
Geek -> creek
You get to meet with Pythagorus.
I put in the color black.
people around us.
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.