I have a class and am trying to build the constructors so I can declare a new class element...
here is my class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
struct nucleotide
{
char nucl;
nucleotide * next;
};
class strandType
{
public:
strandType (); // default constructor
// strandType (char *); // makes a strand from a string
strandType(const strandType & );// copy constuctor
~strandType (); // destructor
private:
nucleotide *strandPtr;
long numInStrand;
};
so (for now...) my main is simple, I just want to get the class working...
1 2 3 4 5 6 7
int main()
{
strandType strand1;
system("pause");
return 0;
}
This is my start at a default and copy constructors...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
strandType::strandType() //default constructor
{
strandPtr = 0;
numInStrand = 0;
}
//strandType::strandType(char * string) //makes a strand from a string
//{
// numInStrand = 4; // I know this is wrong,
// strandPtr = string; // but first things first...
//}
strandType::strandType(const strandType & s)//copy constuctor
{
numInStrand = s.numInStrand;
strandPtr = s.strandPtr;
}
but when I try to compile I get 16 errors shot back at me. For now I would just like to get to the point where I can declare a strandType and have it compile. After that I will worry about declaring a strandType with a string for a parameter.
Thank you for any help anyone can give...
the two errors i get now are:
1) prog2.obj : error LNK2019: unresolved external symbol "public: __thiscall strandType::~strandType(void)" (??1strandType@@QAE@XZ) referenced in function _main
2)C:\Documents and Settings\Jason Cepela\Desktop\School\CIS 200\Program 2\program2\Debug\program2.exe : fatal error LNK1120: 1 unresolved externals
99.99% of the time, "unresolved external error" means the linker cannot find the body of a function (generally because you didn't give it one).
Here, that function is the ~strandType destructor. Give that a body and your errors will vanish.
Also, while not really a problem, you have a bit of a naming inconsistency. It doesn't really matter, but typically you name your .h/cpp files the same name as the class they represent. "prog2h.h" for a file which contains "strandType" is a little bizarre. "strandtype.h" would be more intuitive (I prefer all lowercase filenames as it avoids possible case sensitivity issues on platforms where that matters)