You have to initilialize the FOO in constructor, FOO is a reference and has to initialize in contructor

[CODE]
class baz
{
private:
int foo;

public:
const int & FOO;
baz() : FOO(foo) {} // constructor
~baz(){ } // destructor

};
[/CODE]

Some things got messed up it should be like this:

main.cpp

[CODE]//file1.cpp

include<iostream>
include"file3.h"

using std::cout;
using std::cin;

namespace baz
{
extern MyClass foobar;
}

int main()
{
baz::foobar.setFOO();

baz::foobar.bar();
cout << *baz::foobar.FOO << "\n";

cin.ignore();

return 0;

}
[/CODE]

[CODE]
//file3.h

namespace baz{

class MyClass
{
private:
int foo;

  public:      
  void bar(void);
  void setFOO(void);
  int * FOO;

};

}[/CODE]

[CODE]//file2.c

include"file3.h"

namespace baz
{
MyClass foobar;

void MyClass::bar(void)
{
     foo = 42;
}

void MyClass::setFOO(void)
{
     FOO = &foo;     
}

}

[/CODE]

Hi,

first of all storing a BLOB is very bad design.

But, it would be like this:

[CODE]blob_value = open('image.jpg', 'rb').read()
sql = 'INSERT INTO Tab1(blob_field) VALUES(%s)'
args = (blob_value, )

cursor.execute (sql, args)
connection.commit()[/CODE]

i see, well when i will do it like this:

[CODE]void check_name()
{ name *strt;
strt = start_ptr;
cout << endl;

      for (name * strt = start_ptr;strt->nxt !=NULL;strt=strt->nxt)
      {      

        if (enter_name == strt->boy_name )
        {
            cout << enter_name << " is ranked #" << strt->rank;
            cout << " in popularity among boys.\n" << endl;
            break;
        }
        else if (enter_name == strt->girl_name) 
        {
             cout << enter_name << " is ranked #" << strt->rank;
            cout << " in popularity among boys.\n" << endl;
             break;

        }
      }
cout << enter_name << " is not ranked among the";
  cout << " top 1000 names." << endl;

}[/CODE]

call check_name() after add_names();

Full code:

[CODE]#include <iostream>

include <cstdlib>
include <fstream>

using namespace std;

struct name
{ int rank;
string boy_name;
string girl_name;
name *nxt;
};

name start_ptr = NULL;
name
current;

void add_names();
void check_name();

string enter_name;

int main()
{
start_ptr = new name;
cout << "Please enter a first name to see its ranking" << endl;
cout << "among the top 1000 baby names." << endl;
cin >> enter_name;
cout << endl;
add_names();
check_name();

system("PAUSE");
return 0;

}

void add_names()
{ //name temp, temp2;
//temp = new name;
name prior = new name;// temp;
int ranking;
//int i=0;
string male_name, female_name;
ifstream in_stream("babynames2004.txt");

//in_stream.open; //opens and loads names & ranks from file
if (in_stream.fail())

{
cout << "File failed to open." << endl;
cout << "Program will now close." << endl;
system("PAUSE");
exit(0);
}

in_stream >> ranking>> male_name >> female_name;

prior = ...
mcap61 commented: Saved my a$$. Thanks for your help, I wish i could return the favor. +1

i would do it like this: [url]http://clipboard.it/v/z2b/[/url] no pointers, better to understand.

Hi!

Sorry the [url]http://www.cs.nccu.edu/~gmilledge/co...ynames2004.txt[/url] doesnt work.

I think you should use std::list, and no pointers if it's not neccessary! It will make your wile easier ;)

[CODE] strcpy(can->name, ch );[/CODE]

better use std::string.

he doesn't like:

[CODE]vector<int[3]> resolutions;[/CODE]

should be:

[CODE]vector<int> resolutions;[/CODE]

if you need an array:

[CODE]vector<list<int>> resolutions;[/CODE]

kirennian commented: Problem solved, thanks. +1
__avd commented: Cool link! +6

you need to type cast it:

[CODE]const int constPtr2=(const int)ptr2; [/CODE]

Hi!

I would create a base class, from which the myTemplateClass will inherit.

like this:
[CODE]
class TemplateClassBase{};

template<class C>class myTemplateClass : TemplateClassBase{};[/CODE]
This should be a list:
[CODE]myTemplateClass templateClassPtrArray[10];[/CODE]
This is better:
[CODE]std::list<TemplateClassBase
> templateClassPtrArray;[/CODE]

[CODE]templateClassPtrArray.push_back( new myTemplateClass<int>() );
templateClassPtrArray.push_back( new myTemplateClass<char>() );
[/CODE]

Code is NOT tested, was written from scratch.

When you have no problem to save anything.

I hope i was clear :/

hmm maybe like this:

[CODE]#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
{
int ...

redrum237 commented: brilliant! thank you, just what i was looking for +2

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

[url]http://www.openssl.org/docs/[/url] is your friend

ausrasul commented: good answer +1

like this?

[CODE]#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;

}[/CODE]

You need to assign left and right child

DeadJustice commented: thanks for explaining it to me +3

"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!

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

[CODE]#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 dressed ...