Click here to Skip to main content
15,902,938 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: My Sql Connectiom Pin
Stuart Dootson3-Jul-09 23:22
professionalStuart Dootson3-Jul-09 23:22 
Questionhide a dialog on task bar. Pin
chandu0043-Jul-09 19:12
chandu0043-Jul-09 19:12 
AnswerRe: hide a dialog on task bar. Pin
enhzflep3-Jul-09 19:30
enhzflep3-Jul-09 19:30 
QuestionSend values from Exe to Browser Pin
tgm.arjun093-Jul-09 16:59
tgm.arjun093-Jul-09 16:59 
AnswerRe: Send values from Exe to Browser Pin
David Crow3-Jul-09 17:35
David Crow3-Jul-09 17:35 
AnswerRe: Send values from Exe to Browser Pin
Hamid_RT4-Jul-09 0:00
Hamid_RT4-Jul-09 0:00 
QuestionConstructor Exception Pin
hpjchobbes3-Jul-09 9:08
hpjchobbes3-Jul-09 9:08 
AnswerRe: Constructor Exception Pin
Stuart Dootson3-Jul-09 9:26
professionalStuart Dootson3-Jul-09 9:26 
hpjchobbes wrote:
So what is the normal procedure for this type of situation. Do you normally create a pointer to the object so that you can use the new keyword to create the object?


Yes, that's what I'd do.

hpjchobbes wrote:
If so, is there a way to prevent someone from creating an object and not a point to your class?


Make the constructors private and add a static method that returns a newly allocated object:

class C
{
public:
   static C* MakeNewC() { return new C; }
private:
   C()
   {
   }
};

int main()
{
   C c; // This won't compile
   C* pC = C::MakeNewC(); // This will compile
}


HTH!!!

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionIE automation [modified] Pin
eoloe3-Jul-09 8:08
eoloe3-Jul-09 8:08 
AnswerRe: IE automation Pin
Stuart Dootson3-Jul-09 8:47
professionalStuart Dootson3-Jul-09 8:47 
Questionsimple template question Pin
minkowski3-Jul-09 6:53
minkowski3-Jul-09 6:53 
QuestionRe: simple template question Pin
CPallini3-Jul-09 7:56
mveCPallini3-Jul-09 7:56 
AnswerRe: simple template question Pin
Stuart Dootson3-Jul-09 8:39
professionalStuart Dootson3-Jul-09 8:39 
QuestionSockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 5:07
Manmohan293-Jul-09 5:07 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
«_Superman_»3-Jul-09 5:10
professional«_Superman_»3-Jul-09 5:10 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 5:31
professionalStuart Dootson3-Jul-09 5:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 9:10
Manmohan293-Jul-09 9:10 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 9:21
professionalStuart Dootson3-Jul-09 9:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 9:39
Manmohan293-Jul-09 9:39 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 9:53
professionalStuart Dootson3-Jul-09 9:53 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:21
Manmohan293-Jul-09 10:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:28
professionalStuart Dootson3-Jul-09 10:28 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:31
professionalStuart Dootson3-Jul-09 10:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:48
Manmohan293-Jul-09 10:48 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
SquiZZlo31-Aug-09 14:48
SquiZZlo31-Aug-09 14:48 

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.