programmersbook 17 Junior Poster

I don't see that you use hashTable or hashfunction?

programmersbook 17 Junior Poster
programmersbook 17 Junior Poster

it can be done much easier: http://clipboard.it/v/XUb/

programmersbook 17 Junior Poster

one of your variabes, does not support the >> operator.

Which type are the variables:
lvl
xp
str
spd
acc
hp
inventory?

programmersbook 17 Junior Poster

Your are in the right way.

programmersbook 17 Junior Poster

Well, String is not string. You have to write it in lowercase.

void toString();

should be:

void toString(string &target);

void Employee::toString(string &target){
target = "Name: " + empName + " / Employee Number: " + empNum + " / Hire Date: " + hireDate;
}
programmersbook 17 Junior Poster
programmersbook 17 Junior Poster

this works:

CandyBar cb[3] = { {"Three Musketeers", .33, 200}, 
                                        {"Hershey's", .45, 225}, 
                                        {"Mars", .45, 2250} };
programmersbook 17 Junior Poster

kind like this:

CandyBar cb = {"Hershey's", .45, 225};

Only works at initialization.

Line 11. is already too late

programmersbook 17 Junior Poster

Private attributes are always with "__" double underscore.

jlm699 commented: There's nothing unclear about this post. It states a fact. +3
programmersbook 17 Junior Poster

You welcome!

programmersbook 17 Junior Poster

Works fine for me. Can you provide how and with what you tested it then it's freezes?

programmersbook 17 Junior Poster

hmm maybe like this:

#pragma warning(disable:4786)		// disable debug warning

#include <iostream>					// for cout etc.
#include <vector>					// for vector class
#include <string>					// for string class
#include <algorithm>				// for sort algorithm
#include <time.h>					// for random seed
#include <math.h>					// for abs()

#define GA_POPSIZE		2048		// ga population size
#define GA_MAXITER		16384		// maximum iterations
#define GA_ELITRATE		0.10f		// elitism rate
#define GA_MUTATIONRATE	0.25f		// mutation rate
#define GA_MUTATION		RAND_MAX * GA_MUTATIONRATE
//#define GA_TARGET		std::string("Hello world!")

using namespace std;				// polluting global namespace, but hey...

struct ga_struct 
{
	string str;						// the string
	unsigned int fitness;			// its fitness
};

typedef vector<ga_struct> ga_vector;// for brevity

void init_population(std::string &target, ga_vector &population, // new parameter
					 ga_vector &buffer ) 
{
	int tsize = target.size();

	for (int i=0; i<GA_POPSIZE; i++) {
		ga_struct citizen;
		
		citizen.fitness = 0;
		citizen.str.erase();

		for (int j=0; j<tsize; j++)
			citizen.str += (rand() % 90) + 32;

		population.push_back(citizen);
	}

	buffer.resize(GA_POPSIZE);
}

void calc_fitness(std::string &target, ga_vector &population)//new parameter
{
	//string target = target; // new parameter
	int tsize = target.size();
	unsigned int fitness;

	for (int i=0; i<GA_POPSIZE; i++) {
		fitness = 0;
		for (int j=0; j<tsize; j++) {
			fitness += abs(int(population[i].str[j] - target[j]));
		}
		
		population[i].fitness = fitness;
	}
}

bool fitness_sort(ga_struct x, ga_struct y) 
{ return (x.fitness < y.fitness); }

inline void sort_by_fitness(ga_vector &population)
{ sort(population.begin(), population.end(), fitness_sort); }

void elitism(ga_vector &population, 
				ga_vector &buffer, int esize )
{
	for (int i=0; i<esize; i++) {
		buffer[i].str = population[i].str;
		buffer[i].fitness = population[i].fitness;
	}
}

void mutate(std::string &target, ga_struct &member)//new parameter
{ …
redrum237 commented: brilliant! thank you, just what i was looking for +2
programmersbook 17 Junior Poster

Sorry i dont get the point?!

programmersbook 17 Junior Poster

a little suggestion:

def set_name(self, new_name): #-----------------------------set's a value to a private name?
        if not new_name:
            raise ValueError, "A critter's name can't be the empty string."
        
        self.__name = new_name
        print "Name change successful."
try:
    crit.name = ""
except ValueError, e:
    print e
programmersbook 17 Junior Poster
programmersbook 17 Junior Poster

- http://boost.org - has everything, like sockets, image manipulation, etc..
- sockets?
- OpenCV to capture the webcam

UDP Protocol?

programmersbook 17 Junior Poster

dont use Visual C++, use gcc/MiniGW, ffmpeg is powerfull!

programmersbook 17 Junior Poster

SSL lib have own functions, but it's still the same socket function in SSL Lib

http://www.openssl.org/docs/ is your friend

ausrasul commented: good answer +1
programmersbook 17 Junior Poster

here you go:

#include <iostream>
//#include <conio.h>

using namespace std;

template<typename T, typename C>
T func(T *array,C loc)
{ 
		T ch;
		cout<<"\n which alphabet u want to find: ";
		cin>>ch;

		for(C j=0;j<loc;j++)
		{
			if(array[j]==ch){
			   return j;
			}
		}
	
	return 0;
}


int main()
{
	const int max=10;
	char arr[max];
	int num,i;
	clrscr();

	cout<<"\n enter a number for how many times u want to type alphabet: ";
	cin>>num;

	for(i=0;i<num;i++)
	{
		cin>>arr[i];
	}

  cout << func<char, int>(arr, num) << endl;

   getch();
  
  return 0;
}
programmersbook 17 Junior Poster

like this?

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

//void calculateAverage();
//int calculateGrade();
//void updateFrequency();

int main()
{
	//const int size=10;
	//int debug=size;
    string tmp;
	//int test1[size], test2[size], test3[size], test4[size], test5[size];
	
	ifstream infile;
	/*
	for(int i=0;i<size;i++)
	{
		test1[i]=0;
		test2[i]=0;
		test3[i]=0;
		test4[i]=0;
		test5[i]=0;
	}
*/
	cout<<"Reading from file ''input.txt''..."<<endl;
	infile.open("input.txt");
	
	if( infile ){
	
	    while( getline(infile, tmp ) ){
	        cout << tmp << endl;
	    }
	}
	
/*
	while(size==debug)
	{
		for(int i=0;i<size;i++)
		{
			infile>>test1[i];
			infile>>test2[i];
			infile>>test3[i];
			infile>>test4[i];
			infile>>test5[i];
		}
		debug--;
	}
	
	for(int i=0;i<size;i++)
	{
		cout<<test1[i]<<" "<<test2[i]<<" "<<test3[i]<<" "<<test4[i]<<" "<<test5[i]<<" "<<endl;
	}
	*/
	
	infile.close();
	#ifdef __LINUX 
	system("pause");
	#endif
	return 0;
}
programmersbook 17 Junior Poster

this should help:

void printRetrieve(studentList & students)
{
    cout << "printing list"<<endl;
    
    for( studentList::iterator it = students.begin(); it != students.end(); it++ )
        cout<< *it<<endl;
}

this is a copy, the list wont be altered

enrollStudent(studentList l);
programmersbook 17 Junior Poster

You welcome!

programmersbook 17 Junior Poster

it's not quite right what i did, you need to create a new Node and sign the left anf right child, i sure you can do!

programmersbook 17 Junior Poster

not necessary: std::ifstream read("file.txt", std::ios_base::ate );
std::ios_base::ate = At The End

i tested it ;)

programmersbook 17 Junior Poster

You need to assign left and right child

DeadJustice commented: thanks for explaining it to me +3
programmersbook 17 Junior Poster

Kind of like this:

IS NOT Done, but i hope you get my point.

#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<fstream>
#include <stdlib.h> 

using namespace std;

struct AVLNode{
    public:
    int balance;
	int key;
	string data;
	AVLNode* leftchild;
	AVLNode* rightchild;


};

class AVLTree{

    public:
    AVLNode *root;
    
    /*
	*inserts a new node given the paramaters
    *in a the same fashion as a binary search tree
    *and then checks to see if AVL is violated
    * k is the key of the node which is an integer
    * d is the string for the info field
    * r is the root node of the AVL Tree
    */
    void AVLTreeInsert( int k, string d){
		
	    AVLNode *temp = this->root; 
        AVLNode *critNode = 0;
        AVLNode *Rnode = 0;
        bool critNodeFound = false;	 

	 cout << "what is up here" << endl;
        //cout << temp->key << endl;
	 cout << "i don't know" << endl;
	 	 
        while(  temp != NULL && temp->key != k ){
		
		    if( temp->balance != 0 ){
				critNode = temp;
				critNodeFound = true;
		    }
		    if( k < temp->key ){
				
			 	temp = temp->leftchild;
		    }
		    else
		        temp = temp->rightchild;
		}
		if(  temp != NULL ){
		
		    temp->data = d;
		    return;
		}
		
		/* NEW --------------------------------------------- */
		
		if( temp == NULL ){
		    AVLNode *newNode = new AVLNode();
		    
		    newNode->data = d;
		    newNode->key = k;
		    
		    temp = newNode;
		    
		    root = temp;
		}
		/* NEW end ------------------------------------------ */
		
		temp->data = d;
		temp->key = k;
		temp->leftchild = NULL;
		temp->rightchild = NULL;
		temp->balance = 0;
		
		if( !critNodeFound ){
			
			Rnode = this->root;
		}
		else{
            int d1;
            int d2; …
programmersbook 17 Junior Poster

you miss understand me.

this makes no sense, ok give me a few minutes, i will try to modify your code

AVLNode *temp = new AVLNode;
temp = this->root;
AVLNode *critNode = new AVLNode;
critNode = 0;
AVLNode *Rnode = new AVLNode;
Rnode = 0;
programmersbook 17 Junior Poster
programmersbook 17 Junior Poster

As far as i know, it not possible to compile ffmpeg under Visual C++, it doesn't support the C++ standard. You have to compile it the gcc under linux or MiniGW!

programmersbook 17 Junior Poster

http://clipboard.it/v/Wmb/ Works but it not very efficient!

programmersbook 17 Junior Poster

the only new which i see at line 211....

programmersbook 17 Junior Poster

well, not to be NULL, you should add a AVLTree Object

programmersbook 17 Junior Poster

I never stored an image in my database before but wanted to know how it is done. Thus, i did this example. I normaly store images in folders and then store paths to them in database.

Anyway, I know not to worry about this anymore.

Thanks for sharing your knowledge with me.

and you should keep it this way

programmersbook 17 Junior Poster

"goto" sux! DONT USE IT, it will make your code impossible to read!

i use think you need "goto", when you have bad program design, no question!

programmersbook 17 Junior Poster

I think You cannot display text and image both at the same time unless you use a frame on the page.

That make no sense, of course you can!

programmersbook 17 Junior Poster

.hpp missing, to test it local, can you provide them?

btw, just a hint:

void BinarySTree::copyTree(TreeNode* treePtr, TreeNode* newTreePtr){
    if (treePtr!=NULL){
        newTreePtr == new TreeNode(treePtr->item, NULL, NULL);


        // newTreePtr == new(std::nothrow) TreeNode(treePtr->item, NULL, NULL);
        // newTreePtr -> no memory -> newTreePtr will be NULL
        
        // this will NOT happen!
        // new will throw bad_alloc
        if (newTreePtr ==NULL)
            cout<<"Cannot allocatememory";
        copyTree(treePtr->leftChildPointer, newTreePtr->leftChildPointer);
        copyTree(treePtr->rightChildPointer, newTreePtr->rightChildPointer);
    }else{
        newTreePtr = NULL; //copyEmptyTree
    }
}
programmersbook 17 Junior Poster

you are probably reading/writing a invalid memory.

usually the program just crash, not stop.

programmersbook 17 Junior Poster

The sockets will be still the same, the data will be encrypted.

programmersbook 17 Junior Poster

sure, temp is NULL, but i don't see where you add a new node with "new AVLNode"?

programmersbook 17 Junior Poster

Verrrrryy baddddd!

programmersbook 17 Junior Poster

BAD:

void draw(Carbol a)

GOOD:

void draw(Carbol &a)//referfence
programmersbook 17 Junior Poster

That is the std:: namespace and I doing the code in managed. Thanks.

and what is the problem?

programmersbook 17 Junior Poster

Which compiler do you use??
------------------------------------
Where is no ";" after if()
"Q" != 'Q'
where is no endl after cin

programmersbook 17 Junior Poster
#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
	system("pause");
	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;
	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;
	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	//Game Starts
	  //WAKE UP
	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here are your attributes:"<<endl;
	cout << "Health (HP): \t"<<HP<<endl;
	cout << "Strength (Str): \t"<<str<<endl;
	cout << "Defence (Def): \t"<<def<<endl;
	cout << "Energy (En): \t"<<energy<<endl;
	cout << "Army Size (Army): \t"<<Army<<endl;
	system("pause");
	cout << "Let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*You get …
programmersbook 17 Junior Poster

How about std::set?

programmersbook 17 Junior Poster

That is right, set is has unique elements and is sorted.

Yes is possible, you have to write a own remove function.

like:
- remove only if is already in list/vector
- while not unique

programmersbook 17 Junior Poster
programmersbook 17 Junior Poster

Sorry but to put images/files into the Database, this is the most stupid thing what you can do. FS should take care of it, to the DB! Bad Design!

programmersbook 17 Junior Poster

How does the declaration looks like for f() ?