Declaring only public class members - doesn't work

C

Chee Liang

Hi all,

I was writing some C++ class stuff in VC. After adding a strcpy(),
whenever the program is exiting I receive a "Unhandled exception: user
breakpoint". Growl, I traced assembly line by line, spend one night
wondering why my strcpy() is overwriting data space. But I couldn't
find anything!

When I replace a header file which exports the class declaration as

class xxx{
public:
xxx
}

with the whole declaration

class xxx{
public:
protected:
private:
}

everything falls in place. Big Oops!

So I gather we are not allowed to declare just the public members when
exporting? Are there any other ways to hide private declarations?

Thanks a bunch!
 
C

Cy Edmunds

Chee Liang said:
Hi all,

I was writing some C++ class stuff in VC. After adding a strcpy(),
whenever the program is exiting I receive a "Unhandled exception: user
breakpoint". Growl, I traced assembly line by line, spend one night
wondering why my strcpy() is overwriting data space. But I couldn't
find anything!

When I replace a header file which exports the class declaration as

class xxx{
public:
xxx
}

with the whole declaration

class xxx{
public:
protected:
private:
}

everything falls in place. Big Oops!

So I gather we are not allowed to declare just the public members when
exporting?

You can declare everything public if you want. Your problem lies elsewhere.
Are there any other ways to hide private declarations?

Thanks a bunch!

I can't tell what is wrong from what you have posted. I suggest you start
paring down the code to the minimum number of lines that cause your problem.
If it isn't obvious by then what your problem is, post what you have and I'm
sure the regulars here will try to help you.
 
J

Julie

Chee said:
I was writing some C++ class stuff in VC. After adding a strcpy(),
whenever the program is exiting I receive a "Unhandled exception: user
breakpoint". Growl, I traced assembly line by line, spend one night
wondering why my strcpy() is overwriting data space. But I couldn't
find anything!

Very doubtful that the access specifier has anything to do w/ it.

Take a very good look at your strcpy code, you are probably overwriting the
bounds of the destination string here (or in some other location).
 
A

ak

sounds to me that you got another problem on your hands
a memory overwrite can cause all kinds of strange behavior.

maybe if u post a bit more code we could have a look.

btw strcpy isnt c++, check out the string class instead.

/ak
 
C

Christopher Benson-Manica

ak said:
btw strcpy isnt c++, check out the string class instead.
^^^^
It certainly is, althoug not the C++ that most people will find a use
for given the utility of std::string's.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top