User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,568 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,426 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.

Simple solution to database

Join Date: Sep 2004
Posts: 6,059
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 419
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: Simple solution to database

  #10  
Jun 15th, 2007
>const Cell & Test() {
> return NULL; //I just want to tell something is wrong
There's no such thing as a null reference in C++. If all you want to do is return a single error state, you can follow the same pattern as the iostream library:
operator void*() const
{
  return ( is_null ) ? 0 : this;
}
This returns a null pointer if the cell is null, or a pointer to the object if it's not. If you aren't comfortable working with overloaded type conversions, you can do the same thing with Test:
void *Test() const
{
  return ( is_null ) ? 0 : this;
}
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
All times are GMT -4. The time now is 3:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC