By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

string ok as public causes core dump as public

P: n/a
I have the following class definition

#include <string>
#include "embl.h"
using namespace std;
class Gene{
public:
Gene(EMBL::EmblSaap *cdsinfo,int snp_pos);
private:
string codonseq;
string protein_seq;
string status;
string message;
int readingframe;
// which codon in the protein seq
int codonpos;
// which allele within the codon is the snp based
int allelepos;
string nuc_seq;
};

Within the constructor after filling up the other variables I come
too:-

ahold2=nuc_seq.substr((newsnp_pos-allelepos),3);
cout<<"codon:"<<ahold2<<"\n";
codonseq=ahold2;

newsnp_pos and allelepos are sensible.
When I redefine the class with codonseq as public the code does not
dump core.
I think this problem has something to do with memory allocation, should
I initiliase the strings in someway to prevent this from happening?
regards jake

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jake wrote:
I have the following class definition

#include <string>
#include "embl.h"
using namespace std;
class Gene{
public:
Gene(EMBL::EmblSaap *cdsinfo,int snp_pos);
private:
string codonseq;
string protein_seq;
string status;
string message;
int readingframe;
// which codon in the protein seq
int codonpos;
// which allele within the codon is the snp based
int allelepos;
string nuc_seq;
};

Within the constructor after filling up the other variables I come
too:-

ahold2=nuc_seq.substr((newsnp_pos-allelepos),3);
cout<<"codon:"<<ahold2<<"\n";
codonseq=ahold2;

newsnp_pos and allelepos are sensible.
When I redefine the class with codonseq as public the code does not
dump core.
I think this problem has something to do with memory allocation, should
I initiliase the strings in someway to prevent this from happening?
regards jake


Changing the access specifier (private to public) should have no effect
on the code generated by the compiler since that is a compile-time
construct only. So I'm guessing the problem is elsewhere. Please post
more of your code (preferably a minimal compilable sample that
demonstrates the problem; see
http://www.parashift.com/c++-faq-lit....html#faq-5.8).

Cheers! --M

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.