|
I think there is no way (other to switch to .NET programming).
But do you really need such a feature?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Kishore JP wrote: Is there any other way to do this?
A private constructor is the only way that I know of.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Yep.
Only restricting access to the members using the private keyword will cause an impediment to use it as base classe because the private members of the base class are unavailable in the derivates.
There's not a sealed attribute in C++.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
1. Private constructor to restrict inheritance.
2. Pure virtual member function to restrict object instantiation.
That's all I know.
Maxwell Chen
|
|
|
|
|
You have the technical answers but are you sure you are applying this where needed?
Kishore JP wrote: I dont want any one to inherit my class.
any one? Who are these people?
led mike
|
|
|
|
|
I guess that the OP is making a DLL or something which exports classes ...
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: I guess that the OP is making a DLL or something which exports classes
So exported classes should not be inheritable? I never knew that.
led mike
|
|
|
|
|
led mike wrote: So exported classes should not be inheritable? I never knew that.
The OP's preference.
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: The OP's preference.
Ah, now I understand, it's the developers preference that is used as criteria to determine that a class should not be inheritable. I never knew that.
led mike
|
|
|
|
|
|
"Yes, but why do you want to?"
Thank you, sometimes it's like talking into space, devoid of logic and reason around here.
Last modified: after originally posted -- wow I butchered that post
led mike
|
|
|
|
|
some thing like singleton class will do! old c++ still awaiting sealed class keyword
"If it were machines, the pair_programming seem to work, but for humans it is pair_crackdown that seems to work! " - Nisamudheen
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I have an MFC Dlg Application. Say the project is called Test.
Visual Studio creates a TestDlg.cpp and a Test.cpp among others.
I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp.
I cannot do a static cast of the TestDlg.cpp can I?
|
|
|
|
|
Before calling the dialog's DoModal() method, you can access the dialog's public members.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
"Test.cpp" is where your CTestApp implementation is.
"TestDlg.cpp" is where your main dialog window CTestDlg implementation is.
In "Test.cpp", there is the function CTestApp::InitInstance .
Inside this function body, you can see the variable
CTestDlg dlg;
dlg.DoModal();
So you can do initialization like this:
CTestDlg dlg;
dlg.InitMyMemberValues();
dlg.DoModal();
Maxwell Chen
|
|
|
|
|
Is this the same way of thinking for a View application as opposed to a dlg based?
|
|
|
|
|
LCI wrote: Is this the same way of thinking for a View application as opposed to a dlg based?
This is the C++ object-oriented way.
Maxwell Chen
|
|
|
|
|
What i mean is in a dlg based app we have:
CTestDlg dlg;
dlg.DoModal();
in the initistance.
What is the equivalent for a Single or multiple document based application? In other words , the same original question,just applied to a single or multi0ple document based app instead of a dlg based?
|
|
|
|
|
After the view object has been created, you can access its public members.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
not sure if it's really related to your problem, but have a look at this article[^] anyway...
|
|
|
|
|
LCI wrote: I have an MFC Dlg Application. Say the project is called Test.
Visual Studio creates a TestDlg.cpp and a Test.cpp among others.
I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp.
I cannot do a static cast of the TestDlg.cpp can I?
I would add a CTestDlg member variable to CTestApp and change InitInstance to use that instead of one local to InitInstance.
Nathan
|
|
|
|
|
I want to capture client area of a window.
I am using vc++ and vs2005.
|
|
|
|
|
Be prepared for long stakeout. The client areas only come out at certain hours during the night and tend to be sensitive to noise and light. It takes a lot of skill to capture them.
|
|
|
|
|
Nice joke, I am able to capture a window and also able to solve this image into a file but the problem is i can't print only the client area.
I have also use the flag PW_CLIENTAREA.
Please help to solve this
|
|
|
|