Hello I have actually an error message among others Chromosome.h:16:5: error: ‘Individual’ does not name a type Individual* sequence; thanks the code for Chromosome.h is:


You watching: Does not name a type c++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef CHROMOSOME_H #specify CHROMOSOME_H #incorporate "defs.h" #include "Individual.h" class Chromosome ; #endif
does not name a type - C++ Forum
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


See more: How To Say You Re Welcome In Russian & You'Re Welcome, Thank You In Russian

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include #incorporate #encompass #incorporate using namespace std; #include "Individual.h" #include "Chromosome.h" Individual::Individual(string f, string o) // Cuts off digits previous size :factor(f),operacion(o) Individual::~Individual() Chromosome* Individual::getChromosome() int Individual::getChromosomeLength() void Individual::setGene(int counter, Individual *gene) Individual Individual::getGene(int offset) void Individual::setFitness(double fit) double Individual::getFitness() void Individual::printChromosome() void Individual::setFactor(string factor) void Individual::setOperacion(string operacion) string Individual::getFactor() string Individual::getOperacion() string Individual::toString() string Individual::getFormula(vector* ram, int n) else } private: string factor; string operacion; }
Last edited on May 6, 2019 at 2:03pm UTC
*
May 6, 2019 at 2:08pm UTC
jonnin (8751)
from what you gave us, your incorporate order and also all look correct. so I am going to ask around "various other errors" in your comment. If you have errors in the individual course itself, then it will not register as a form, and youll get this further down. Which goes ago to the "deal with the top error and hit go again" for tiny jobs (clearly must look even more once you get to stuff that takes even more than a min or 2 to compile). if all else stops working try to compile a stub project via simply the individual course and also one circumstances of it in main.
Last edited on May 6, 2019 at 2:09pm UTC
*
May 6, 2019 at 2:37pm UTC
Ganado (5818)
It"s constantly difficult for to follow this type of error without having actually the code in front of me, yet I think tright here actually is a possible dependency problem here. There error is happening in Chromosome.h... based upon the code you"re offering, let"s assume it"s not compiling individual.cc correctly. When we initially go to compile individual.cc, first we #include Individual.h. But... I can watch from this line Chromosome* Individual::getChromosome() That you require Individual to know what a Chromosome is (my guess is that an Individual has-a Chromosome)! So I assume you"re trying to #encompass Chromosome.h within Individual.h. So you have actually a circular dependency. I suggest trying out this dependency to view it yourself. One (possible) solution that I can"t test is: Due to the fact that the interpretation for Chromosome only depends on pointers to Individual, you do not need to #include Individual.h inside Chromosome.h. Just declare it as being a class class Individual; rather, wright here you offered to #incorporate it in the header.
Last edited on May 6, 2019 at 2:40pm UTC
*
May 6, 2019 at 3:02pm UTC
psosmol (71)
Certainly I have many error messages: In file contained from Individual.h:5, from Population.h:5, from GeneticAlgorithm.h:3, from main.cc:12: Chromosome.h:8:28: error: supposed ‘)’ before ‘*’ token Chromosome(Individual<>*, int); ~ ^ ) Chromosome.h:16:5: error: ‘Individual’ does not name a kind Individual* sequence; ^~~~~~~~~~ In file included from Population.h:5, from GeneticAlgorithm.h:3, from primary.cc:12: Individual.h:11:22: error: expected ‘)’ prior to ‘,’ token Individual(string, string); ~ ^ ) Individual.h:27:17: error: ‘string’ has not been declared void setFactor(string); ^~~~~~ Individual.h:28:20: error: ‘string’ has not been declared void setOperacion(string); ^~~~~~ Individual.h:29:2: error: ‘string’ does not name a type; did you suppose ‘stdin’? string getFactor(); ^~~~~~ stdin Individual.h:30:2: error: ‘string’ does not name a type; did you intend ‘stdin’? string getOperacion(); ^~~~~~ stdin Individual.h:31:2: error: ‘string’ does not name a type; did you intend ‘stdin’? string toString(); ^~~~~~ stdin Individual.h:32:2: error: ‘string’ does not name a type; did you expect ‘stdin’? string getFormula(vector*, int); ^~~~~~ stdin Individual.h:35:2: error: ‘string’ does not name a type; did you intend ‘stdin’? string factor; ^~~~~~ stdin Individual.h:36:2: error: ‘string’ does not name a type; did you suppose ‘stdin’? string operacion; ^~~~~~ stdin
*
May 6, 2019 at 3:08pm UTC
Furry Guy (2732)
Chromosome.h:8:28: error: supposed ‘)’ before ‘*’ token Chromosome(Individual<>*, int); Are you trying to pass a 1 dimensional variety or 2D? The various other parameter renders me think 1D. Chromosome(Individual<>, int); The rest of the errors are difficult to number out, you didn"t article your Individual.h file.
Last edited on May 6, 2019 at 3:12pm UTC
*
May 6, 2019 at 3:11pm UTC
jonnin (8751)


See more: Most Expensive Vendor Item In Wow, What Is The Most Expensive World Of Warcraft Item

did you forgain to include ? and you need std::string if you do not have the worldwide namearea pulled in (a poor practice for large programs). (Yes I watch string in these files, however is it necessary & lacking in your .h file for individual? I can"t tell..) Aget, I think you have to grab just the individual course, stuff that in a stub major regimen and acquire that to compile. Then try this one aget. It will certainly make it much easier to deal with. We can"t assist you... looks like we are absent some of the code.

Categories: Q&A