having constructor troubles, using class w. pointers

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...
I don't see anything wrong. What errors are you getting?

Only thing I can think of is you're not #including your header where it needs to be (assuming the class is defined in its own header)
alright I've been messing around with my "#includes" and now am receiving 2 errors.
my header file with the class in it starts out like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
using namespace std;

#ifndef STRAND_H
#define STRAND_H

struct nucleotide
{*****};

class strandType
{*****};

#endif 


my main file has:
1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
#include<string>
using namespace std;
#include"prog2h.h"


int main()
{ strandType strand1; 
   system("pause");
  return 0;
}



and my implementation file has got:
1
2
3
4
5
6
7
8
9
10
#include<iostream>
#include<string>
using namespace std;
#include "prog2h.h"

strandType::strandType() //default constructor
**
**
**
**


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)
Topic archived. No new replies allowed.