473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

string ok as public causes core dump as public

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
1 1810
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christophe Elek | last post by:
Ok, I am completly at lost :) in both cases (my Yenc and zip utilities) i try to do the following 1) get a String 2) transform in byte 3) so some computation (either adding value to the byte...
6
by: John Liu | last post by:
I've two questions, they may or may not be related - 1. I copied the entire data directory from postgreSQL 7.3.2 (AIX4.3) to the installation postgreSQL 7.3.4 (AIX5.1), the same filesystem setup....
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
3
by: John Liu | last post by:
AIX pg version 7.4 Select * from document2 core dump. Did a few more experiments with select * from document2 limit... I limit to 500000 it works, 600000 it exits but says "calloc:...
4
by: Vincent | last post by:
Hello, Does anyone have a problem with Apache2 crashing after executing a PHP script with session_start()? I notice if session_start() is placed anywhere except at the start of the file, APache...
58
by: manoj1978 | last post by:
Hi All, I wrote the following to print an integer in its string representation for base -36 to 36. Please comment on this code. #include <iostream> #include <string> using std::abs; using...
10
by: mr_sorcerer | last post by:
Hi! I just found something interesting. I mean what do you think about this: char *p = 0; std::string str = p; Why std::string doesn't check null pointers?
4
by: loudking | last post by:
Hi, all Here is part of my code. ======================================== void *record; /* treat record */ if (record) {
14
by: Sheldon | last post by:
Hi, Can anyone tell me why this script file.c and file.h causes a core dump when it is compiled and run? Any help is appreciated. Sheldon snip....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.