|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How can I prevent a class from being inherited?
My idea is to declare the constructor of the base class to be prviate. Is it correct?
For example
class A
{
private:
A() {};
public:
~A() {};
}
class B : public A
{
public:
B() {};
~B() {};
}
int main()
{
B b;
return 0;
}
As I compile the program, error C2248 happen. Is it all right?
Is there any good idea of preventing a class from being inherited?
many thanks.
|
|
|
|
|
Have a look at sealed keyword.
|
|
|
|
|
Excuse me, I can't find any subjects I want in your articles.
Can you give me a link to it or say in more details?
thanks.
|
|
|
|
|
I didn't mean my articles, it's just my signature. Just look up sealed keyword.
|
|
|
|
|
oh, I see. I have found the topic through keyword research.
Thank you very much indeed.
|
|
|
|
|
You are welcome
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI and I wanted to bring up a properties page when an object/control is right-clicked on. It seems that I can have all kinds of general mouse events but how do I determine if the left button was clicked (pressed down, let up, etc.) or the right button was clicked? And what about three button mice and mice with thumb-wheels?
Thanks
Buck
|
|
|
|
|
Handle the MouseDown event and check the Button property of MouseEventArgs parameter that is received by the eventhandler
|
|
|
|
|
Thanks, works great, lasts a long time.
Buck
|
|
|
|
|
how do i make an icon for my c++ program?
iam using borland turbo c++5.01 version on windows xp.
|
|
|
|
|
zulfi123786 wrote: using borland turbo c++5.01
By definition, this means you're not using C++/CLI and are in the wrong forum. The Visual C++ forum is the closest we've got to Borland.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Just more proof that the forums aren't clearly/appropriately marked
"Visual C++" should be called "Native/Unmanaged C/C++"
and this forum should be called "Managed C++ and C++/CLI"
-- modified at 11:59 Monday 15th October, 2007
And of course I just noticed this forum says "(Managed)" at the top of its name. :/
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I know this sounds like a stupid question but i can't seem to get a for each loop to compile correctly.
I tried...
for each (IpAddress ^addr in ipAddresses) {
}
and...
IpAddress^ addr = nullptr
for each (addr in ipAddresses) {
}
but none of them compile. I know i could do a for loop but i would rather just do a for each. I searched but i cant seem to find anyone else having this problem. Thanks alot for any help
here are some of the errors:
Error 1 error C2143: syntax error : missing 'in' before '^'
Error 2 error C2065: 'addr' : undeclared identifier
Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
teejayem wrote: here are some of the errors:
And what are the other errors? Sometimes some errors are caused because of the errors that occur before them. I guess these are errors for the first case. Your code should look like this:
<br />
foreach (IpAddress^ addr in ipAddresses)<br />
{<br />
<br />
}
|
|
|
|
|
hey Giorgi thanks for your reply.
these are some of the errors i get.
Error 1 error C2143: syntax error : missing 'in' before '^'
Error 2 error C2065: 'addr' : undeclared identifier
Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)
array<IPAddress^>^ ipAddresses = Dns::GetHostAddresses(Dns::GetHostName());
for each (IpAddress ^addr in ipAddresses) {
}
i don't think it is any other part of the code that is failing because as soon as i comment the for each loop it compiles fine. Thanks,
-- modified at 9:43 Thursday 11th October, 2007
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
array<System::Net::IPAddress^>^ ipAddresses =
System::Net::Dns::GetHostAddresses(System::Net::Dns::GetHostName());
for each(System::Net::IPAddress^ addr in ipAddresses)
System::Console::WriteLine( addr->ToString());
|
|
|
|
|
can anyone code the VRP problem using genetic alogrithms in c++.
i need that to be done as a report along with code to submit for my exam.
kindly help me in this work
|
|
|
|
|
Really....don't cross post.
That means don't post the same question on several discussion boards.
Pick the one that best fits your topic.
Also, this isn't a "we do your homework" site. I bet if you offer lots of money you'll
get a better response.
If you're unable to offer large sums of cash, then show us a little of what you've already
done, along with a description of specific problems you're having, and maybe we'll try to help.
If you choose this route, please post on the correct discussion board.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thankyou very much for ur great criticism.due of lack of knowledge on that project only im on this website.a simple answer is enough to let me know ur possibility.
have a nice time
|
|
|
|
|
|
|
Hi all,
I am using ipl98 library version 2.20 and I was compile it successful. However, I can only use the static library is created by VC++.net (It can run ok with the example in ipl98 library project.) The dynamic library cannot use it to run the example.
About Borland C++, I also compile successfully but the dynamic library cannot do with the example. After that I compile it to create the static library, this is not successful, the error: library too large, please restart with library page size 32.
My purpose is using ipl98 library version 2.20 in the Borland C++. However, I spent a lot of time but until now I also cannot use it in the Borland C++. If you have any advices, any ideas, or any instructions please show me!
Can we use the static library created by VC++.net to transition dynamic library? Or Can we use the static library in Borland C++? Or you have another ways to solve it.
I hope I will get your feedback as soon as possible.
Best regards!
nothing
|
|
|
|
|
Tien Manh wrote: My purpose is using ipl98 library version 2.20 in the Borland C++.
Unless this version of Borland supports Microsoft .NET libraries, and they are used by this dll, you're in the wrong forum. The Visual C++ forum is the place for non .NET C++ questions, even then, I doubt many people here use Borland.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
a simple program of a class (combined) containing a member which is an object of another class (alpha).
When the object of combined class is instantiated, copy constructor for alpha is called twice!!
class alpha<br />
{<br />
int alpha_value;<br />
public:<br />
alpha() { std::cout << "\nCalled constructor for alpha"; }<br />
alpha(const alpha&) { std::cout << "\nCalled copy constructor for alpha";}<br />
};<br />
<br />
<br />
class combined<br />
{<br />
alpha a;<br />
public:<br />
combined() {std::cout << "\nCalled constructor for combined}";}<br />
combined(alpha& a1): a(a1) { std::cout << "\nThree argument Constructor Called for combined"; }<br />
};<br />
<br />
<br />
int main()<br />
{<br />
alpha a;<br />
combined d = combined(a);<br />
return 0;<br />
}
Following is the output:
Called constructor for alpha
Called copy constructor for alpha
Three argument Constructor Called for combined
Called copy constructor for alpha
Manik
|
|
|
|