Click here to Skip to main content
16,011,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Array of Pointers to Surfaces Pin
Nick Parker20-Jun-03 18:12
protectorNick Parker20-Jun-03 18:12 
GeneralRe: Array of Pointers to Surfaces Pin
Michael Dunn20-Jun-03 18:14
sitebuilderMichael Dunn20-Jun-03 18:14 
Questioncan i send a popup message by programming in windows 98? Pin
Hendy_So20-Jun-03 16:59
Hendy_So20-Jun-03 16:59 
AnswerRe: can i send a popup message by programming in windows 98? Pin
Ryan Binns21-Jun-03 1:01
Ryan Binns21-Jun-03 1:01 
GeneralRe: can i send a popup message by programming in windows 98? Pin
Hendy_So21-Jun-03 22:42
Hendy_So21-Jun-03 22:42 
GeneralRe: can i send a popup message by programming in windows 98? Pin
Ryan Binns21-Jun-03 22:46
Ryan Binns21-Jun-03 22:46 
QuestionHow to enable Unicode character support in CRichEdit control Pin
Saqib Razzaq20-Jun-03 14:34
Saqib Razzaq20-Jun-03 14:34 
QuestionHow to return NULL when return type is user defined Pin
Anonymous20-Jun-03 13:07
Anonymous20-Jun-03 13:07 
Please read this code and the question asked at the end.

class Point
{
private:
int x, y;
public:
Point();
Point(int x, int y); //constructor
int getX(); // getter
int getY(); // and
void setX(int x); // setters
void setY(int y); // functions
bool operator==(Point p) const; //overloaded == operator
~Point(); // destructor
};

class Box
{
private:
Point points[40];
public:
Point findPoint(Point p); //what should be the prototype of this function

};

Point Box::findPoint(Point p)
{
Point pTemp;
for(int i=0; i<40; ++i)
{
pTemp = points[i];
if( pTemp == p )
return pTemp;
}
return; // what to return here ?????????????
}


Look at the findPoint function. The responsibility of this function is to search in arrary
for the Point given and if function finds this Point, return it, otherwise if function does
not find the Point given it should return NULL. But I am unable to do it. I can achieve this
by changing the prototype of function like this

Point *findPoint(Point p);

butt I dont want to do this because it will break the conecpts of OOP and give access to
private data memeber.

The problem is if I return by value then I cant return NULL, so in user class or function,
I can not know whether the Point is found or not. and if I return the pointer, then I give
direct access to private data member.

Anybody help please !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
AnswerRe: How to return NULL when return type is user defined Pin
nfactorial20-Jun-03 13:24
nfactorial20-Jun-03 13:24 
GeneralRe: How to return NULL when return type is user defined Pin
Hashim Saleem20-Jun-03 13:37
Hashim Saleem20-Jun-03 13:37 
GeneralRe: How to return NULL when return type is user defined Pin
nfactorial20-Jun-03 13:47
nfactorial20-Jun-03 13:47 
GeneralRe: How to return NULL when return type is user defined Pin
Hashim Saleem20-Jun-03 14:13
Hashim Saleem20-Jun-03 14:13 
GeneralRe: How to return NULL when return type is user defined Pin
nfactorial20-Jun-03 14:37
nfactorial20-Jun-03 14:37 
GeneralRe: How to return NULL when return type is user defined Pin
Hashim Saleem20-Jun-03 15:06
Hashim Saleem20-Jun-03 15:06 
AnswerRe: How to return NULL when return type is user defined Pin
Neville Franks20-Jun-03 13:32
Neville Franks20-Jun-03 13:32 
Generaldrive information Pin
snipes20-Jun-03 12:48
snipes20-Jun-03 12:48 
GeneralRe: drive information Pin
kochhar20-Jun-03 18:45
kochhar20-Jun-03 18:45 
QuestionVisual C++ profiler? Pin
Marcus Spitzmiller20-Jun-03 11:44
Marcus Spitzmiller20-Jun-03 11:44 
AnswerRe: Visual C++ profiler? Pin
Saqib Razzaq20-Jun-03 12:28
Saqib Razzaq20-Jun-03 12:28 
GeneralRe: Visual C++ profiler? Pin
Marcus Spitzmiller20-Jun-03 15:43
Marcus Spitzmiller20-Jun-03 15:43 
QuestionHow to replace default keys behaivour in Edit control Pin
Saqib Razzaq20-Jun-03 10:42
Saqib Razzaq20-Jun-03 10:42 
AnswerRe: How to replace default keys behaivour in Edit control Pin
User 665820-Jun-03 10:48
User 665820-Jun-03 10:48 
GeneralRe: How to replace default keys behaivour in Edit control Pin
Saqib Razzaq20-Jun-03 11:12
Saqib Razzaq20-Jun-03 11:12 
GeneralRe: How to replace default keys behaivour in Edit control Pin
User 665820-Jun-03 11:23
User 665820-Jun-03 11:23 
GeneralSerialize Pin
Anthony988720-Jun-03 10:12
Anthony988720-Jun-03 10:12 

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.