|
after learning the rule of C++,i still could not write a beautiful program like MSM or QQ, what should i do ? Shall i learn MFC or others ?i want to use SDK
|
|
|
|
|
First decide which language you wish to use, and then read books, check the internet for useful resources. Take a look at some of the articles[^] here on CodeProject, you will find many useful samples and tutorials.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Those are web based chats... so you should probably learn about doing web (or cloud) based applications and their relevant tools/frameworks. You can do it with C++ as well, but at that point you're probably working at a lower level than you have to.
|
|
|
|
|
template <typename String1>
void CompareText()
{
GUESSWHAT<String1> comparator;
String1 val1 = "abc";
String1 val2 = "xyz";
ISSAME(comparator(val1, val2), true);
}
ISSAME is the macro which can takes 2 vals.
Please let me know the meaning of "comparator".What is it(Function / object / Declaration)?
Also please let me know the declaration & defination of GUESSWHAT.
|
|
|
|
|
Member 1544087 wrote: Please let me know the meaning of "comparator".What is it(Function / object / Declaration)?
Looks like a function.
Member 1544087 wrote: Also please let me know the declaration & defination of GUESSWHAT.
Looks like a macro, but since you have not provided its definition we can only guess.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have to write defination of GUESSWHAT...
I am not having it with me.
I think, its a template. But I am not sure, how it should be declared.
|
|
|
|
|
Member 1544087 wrote: I have to write defination of GUESSWHAT...
So I guess it's your homework or college assignment, which means you should have some lecture notes that explain what is required. As I said before we cannot guess what you need to provide based on this information. The best I can suggest is that you read up on templates[^] to get some possible answers.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hi:
i overload the operator new, codes shown as below:
void * __cdecl operator new(unsigned int size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
return ptr;
}
and when i want to create a class object
CTest::CTest()
{
int a = 0;
}
CTest::~CTest()
{
int b = 0;
}
int main()
{
CTest* test = new CTest;
delete test;
return 0;
}
it is very obvious that i overload the operator new by malloc, so when i use the overloaded new operator to create a class object, the CTest's construction should not be called, while the result is complete opposite. And
my question: why the class's construction function can be called when i create it by malloc but not new?
|
|
|
|
|
I think you need to make your overload a member of the CTest class; see here[^] for further details.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Voted a 4: although you're right about the class operator new being called first, it will eventually call the global new within it, don't think the compiler allows you to dodge the constructor with the new keyword. See the link I provided below...
It's really a good question because I never tried to do this before.
|
|
|
|
|
Albert Holguin wrote: it will eventually call the global new within it
This is all explained in the MSDN link I provided in my answer.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Overloading operator new only affect how memory is allocated. The constructor of your class is always called.
By the way, it has nothing to do with C++/CLI and thus, it is in the wrong forum.
Philippe Mori
|
|
|
|
|
|
It is defined by the standard to works that way. By the way, why would you wany to override operator new. It is hard to do correctly and efficiently.
And it C++, it never a good idea to create an object without calling its constructor. Thus why you would want it that way?
Also, if you override new, then you should probably override delete also to have a matching implementation.
Philippe Mori
|
|
|
|
|
1. Can I pass the CommVariant to other function, when not created using new ?
2. Should I free it/delete expecitly some where ?
3. Is it safe ?
<pre>CComVariant comVariant;
comVariant.vt = VT_I4;
comVariant.intVal = 10;
SendComVariantToOtherFunction(comVariant);
Thanks in advance!!
|
|
|
|
|
I'm new to C++ and am running into another hicucp I'm hoping someone can help me with. I'm looking to change the opacity on a form when the mouse enters it (to 100%), and then dim it again when the mouse leaves the Windows form. I can almost get things to work, but I'm seeing oddities that I think are due to the fact that it "enters" other controls that are on the form. Here's what I've been tinkering around with:
private: System::Void MyForm_MouseHover(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 1.00;
}
private: System::Void MyForm_MouseLeave(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 0.50;
}
private: System::Void MyForm_MouseEnter(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 1.00;
}
Can someone explain to me how I can prevent my code from repeatedly reading things until the cursor leaves the entire form?
Thanks!
|
|
|
|
|
I NEED HELP WITH THE FOLLOWING:
Write a class called Thermometer. The thermometer should have the following features:
• Return the current temperature in either C or F (conversion)
• Reset the temperature to zero (if the current scale is C) or 32 (if the current scale is F)
• Set the scale of the thermometer to either C or F
• Set the temperature
• Return the current scale
• Provide a copy constructor to make a copy of a Thermometer
All data members of your class should be private. You should include a constructor to initialize the Thermometer object to 0˚ C, as well as a constructor that accepts a temperature and scale to initialize to. You will also need a copy constructor.
|
|
|
|
|
What exactly do you need help doing?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I need help with the copy constructor.
|
|
|
|
|
So, what's the problem ?
This looks like a nice homework for entry level programming.
I assume you have course notes, documentation, discuss the problem with your friends and class mates, ask questions to your teacher and/or lab assistant.
Watched code never compiles.
|
|
|
|
|
include "ClassCons2.h"
#include <iostream>
using namespace std;
class ThermoClass {
private:
char C;
char F;
float temp;
ThermoClass();
SetTemp(float atemp);
SetTheScale(char C, F);
GetTemp();
Scale = 'C';
};
int main ()
{
ThermoClass::Thermoclass (float) {return afloat};
ThermoClass thermoObject;
thermoObject.SetTheScale;
return Scale;
}
THIS IS WHAT I'VE DONE SO FAR. I NEED TO KNOW IF I'M ON THE RIGHT TRACK
|
|
|
|
|
It looks like you have a lot to learn about classes. You have created a class with a number of elements that do not seem to have any purpose. You have also not written the implementation of any of the class methods. I would suggest spending some more time with your course notes learning how to create simple classes and how the various parts fit together (constructors, properties, methods etc.).
You could also use the MSDN documentation[^] to help clarify what a class is.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
1. Write the class without the copy constructor.
2. Review you class notes and text book paying attention to what it says about copy constructors.
3. Using 2 add code to 1 to make a copy constructor.
|
|
|
|
|
I'm new to C++ and still learning a ton, and I'm hoping that someone can point me in the right direction to solve a problem (my Google-fu has failed me). I have a Windows form that displays on the the screen, and everything works just fine. My problem is that I want it to fade in when it's opened, and fade out when it's closed.
I can't seem to find any good C++ examples (that I can understand). Can anyone shed some light on this for me? Thanks!
|
|
|
|
|
Uses a timer and increase the opacity until the form is fully opaque.
Philippe Mori
|
|
|
|