Click here to Skip to main content
15,896,312 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problems with realloc - heap corruption Pin
Zac Howland7-Sep-06 8:39
Zac Howland7-Sep-06 8:39 
AnswerRe: Problems with realloc - heap corruption Pin
Stephen Hewitt8-Sep-06 2:03
Stephen Hewitt8-Sep-06 2:03 
QuestionAnother impossible question Pin
Waldermort7-Sep-06 6:50
Waldermort7-Sep-06 6:50 
AnswerRe: Another impossible question Pin
JWood7-Sep-06 7:09
JWood7-Sep-06 7:09 
GeneralRe: Another impossible question Pin
Waldermort7-Sep-06 7:15
Waldermort7-Sep-06 7:15 
GeneralRe: Another impossible question [modified] Pin
Anonymuos7-Sep-06 11:38
Anonymuos7-Sep-06 11:38 
AnswerRe: Another impossible question Pin
Jun Du7-Sep-06 7:36
Jun Du7-Sep-06 7:36 
QuestionRe: Another impossible question Pin
Zac Howland7-Sep-06 8:50
Zac Howland7-Sep-06 8:50 
Are these public members variables or functions?

If these are functions, you can use something like the Pimpl-Idiom to hide the implementation a bit, so that if they subclass it, they won't have access to the "meat" of the object. For example:

// in the header file
class _MyClass;
class MyClass
{
public:
	MyClass();
	~MyClass();	// declare as virutal if you want this to be able to be derived from
	void someFunc();
	// whatever other functions you want
private:
	_MyClass* m_pImpl;
};

// in the implementation
class _MyClass
{
public:
	_MyClass()
	{
	}

	void someFunc()
	{
		// do whatever
	}
};

MyClass::MyClass() : m_pImpl(new _MyClass)
{
}

MyClass::~MyClass()
{
	delete m_pImpl;
}

void MyClass::someFunc()
{
	m_pImpl->someFunc();	
}


That way, deriving from MyClass would allow them to call the MyClass public/protected methods, but have no access to the actual data and can't circumvent (at least not easily) any requirements you are trying to place on the class.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

AnswerRe: Another impossible question Pin
Waldermort7-Sep-06 18:41
Waldermort7-Sep-06 18:41 
Questionpreprocessor directive Pin
Lord_Vader7-Sep-06 6:49
Lord_Vader7-Sep-06 6:49 
QuestionRe: preprocessor directive Pin
David Crow7-Sep-06 8:18
David Crow7-Sep-06 8:18 
AnswerRe: preprocessor directive Pin
Chris Losinger7-Sep-06 8:22
professionalChris Losinger7-Sep-06 8:22 
AnswerRe: preprocessor directive Pin
Hamid_RT8-Sep-06 7:28
Hamid_RT8-Sep-06 7:28 
QuestionMFC Toolbar handle Pin
ninolaroca7-Sep-06 6:05
ninolaroca7-Sep-06 6:05 
Questionwprintf failing me Pin
Waldermort7-Sep-06 5:33
Waldermort7-Sep-06 5:33 
AnswerRe: wprintf failing me Pin
Zac Howland7-Sep-06 5:50
Zac Howland7-Sep-06 5:50 
GeneralRe: wprintf failing me Pin
Waldermort7-Sep-06 5:56
Waldermort7-Sep-06 5:56 
GeneralRe: wprintf failing me Pin
Waldermort7-Sep-06 5:59
Waldermort7-Sep-06 5:59 
GeneralRe: wprintf failing me Pin
Zac Howland7-Sep-06 6:15
Zac Howland7-Sep-06 6:15 
GeneralRe: wprintf failing me Pin
Waldermort7-Sep-06 6:38
Waldermort7-Sep-06 6:38 
AnswerRe: wprintf failing me Pin
led mike7-Sep-06 5:59
led mike7-Sep-06 5:59 
Questiondelete files past a certain date Pin
si_697-Sep-06 4:18
si_697-Sep-06 4:18 
AnswerRe: delete files past a certain date Pin
led mike7-Sep-06 5:00
led mike7-Sep-06 5:00 
AnswerRe: delete files past a certain date Pin
Chris Losinger7-Sep-06 5:00
professionalChris Losinger7-Sep-06 5:00 
AnswerRe: delete files past a certain date Pin
krmed7-Sep-06 6:54
krmed7-Sep-06 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.