Friend class

Hello people,

I am trying to work with a friend class but for some reason when I want to cout my variable of interest it returns a memory space (I think so)
Can anybody help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class PopulationFrequency
{

friend class Evolution;

protected:
	
private:
	short loci;
	int arraysize;
	//int matcomb;
	double* genotypefrequency;
	int* relativePopulationSample(double*,int);
	int* matingOptions(int*, int*);

public:
	PopulationFrequency();
	PopulationFrequency(int);
	void setGenotypeFrequency(double newgenotypefrequency[]);
	double getGenotypeFrequency(int);
	double* computeProbability(double*);
	//double** matingProbability(double*);
	double* setOffspring(double*, int);
	void setMutation(int, int);

};

Evolution::Evolution(int npopulationsRow, int nloci)
{
	popsizerow = npopulationsRow;

	int npopulations = npopulationsRow*npopulationsRow;
	//cout<<npopulations;
	for(int i=0; i<npopulations; i++)
	{
		objarray.push_back(PopulationFrequency(nloci));
		/*
		cout<<i;
		for(int l=0;l<27;l++)
		{
			cout <<" "<<objarray[i].getGenotypeFrequency(l);
		}
		cout<<"\n";
		*/
	}
	//cout<< "Science bitches"<<"\n";
	//cout<<objarray.size();
	getNeigbours();
}

void Evolution::populationMigration(double migrationrate)
{
	int npop = popsizerow*popsizerow;
	
	PopulationFrequency test;

	cout<<test.arraysize;

}


joez
PopulationFrequency::arraysize is an int, it won't write a space. You need to double check your output.

Also, don't use friends. It's almost always used inappropriately.
Topic archived. No new replies allowed.