Code Project » C / C++ / MFC
74 FOLLOWERS
CodeProject is a place for those who code. This section gives you a space to ask questions and queries about the code, errors, Azure DevOps, and many such resources on C and C++ .
Code Project » C / C++ / MFC
1d ago
I have one more question.
I will try my best to describe the issue and hoping the discussion does not get centered on terminology and RTFM as in the past.
That is not an instruction on how to reply, just a polite request to get real and skip opinions.
( And if you think me saying this is rude...
I am just trying to get of the dime and writing it as politely as I know)
I did have resolved the syntax of "passing the class" , however now I am stuck with WHERE the class should be declared.
In layman terms - the calling object passes a class pointer to the function, which happens to be my own cre ..read more
Code Project » C / C++ / MFC
1d ago
This post original subject - error: declaration of anonymous class must be a definition
was caused by this class declaration
< class REG_EXP //regular_expression_class
{
int a;
QString text;
QString RegExp;
QString Analyze;
} TEST_REG_EXP;
/pre>
Search for the symbol "REG_EXP" in the entire project returned no result.
The conclusion
it is unknown why the error was posted.
Please consider this matter closed ..read more
Code Project » C / C++ / MFC
3d ago
I am trying to improve my C++ skills and could use some advice.
I am using event driven tool - I am not allowed to say the name here -
and my basic question is
if I create an instance of a class which uses a library
should the library by instantiated in class constructor
as a common to all class methods variable
or
be instantiated in each method ( as a local method variable ) as needed ?
Process speed is immaterial, my question is about how is
memory allocated / de-allocated ( managed by C++) during the events ..read more
Code Project » C / C++ / MFC
5d ago
UPDATE
DONE
"Match any number of characters , (from start of the line) , until "new line \n " is reached :
QRegularExpression re( ".*\n");
TODO
match first word only (of each line )
match the entire text (first word of each line )
I am VERY sorry to be such bother, but I am actually looking
for someone / somebody willing to help me to interpret ( read) the Linux
regular expression manual to build the expression.
My task is to
match each and every FIRST word in multi-line string .
I am stuck at
"\w+"
which matches EVERY word in the entire text
I can post my current code when I get
"I ..read more
Code Project » C / C++ / MFC
1w ago
I am trying to learn how to pass class pointer ,
so if that is too basic to ask here....no instruction posted...
I have started with this and it works as expected :
C++
<pre> // test using AddFive
{ // test using AddFive code block
int nMyNumber = 18;
printf("My original number is %d\n ", nMyNumber);
qDebug("QDebug My original number is %d\n ", nMyNumber);
text = " My original number is %d\n";
text ..read more
Code Project » C / C++ / MFC
1w ago
UPDATE
Did I post this in wrong church / wrong pew ?
I am really trying to learn how regular expression works.
So
I expect this to match FIRST and only word in the text and its "new line ".
It does not.
"\\w+ [\n]"
neither does this
"\\w+ [\\n]"
this still works
"\\w+"
can somebody PLEASE tell me what is wrong with my regular expression syntax?
I am looking for ANY document actually tells HOW the build regular expression .
( Regular expression for dummies...)
Ideally something converting verbal description to regular expression, in any fashion.
There are few tools likes this
C ..read more
Code Project » C / C++ / MFC
2w ago
I'm trying to straighten out some pointer "arithmetic" in some existing code. The expressions themselves are overly ambiguous to say the least. In part of my readings, I've come across the "auto" keyword where the compiler deduces what type I need. At least that's what I got from all of the verbiage.
This seems a) dangerous and b) adds another level of mental indirection to what you are trying to accomplish. To me, software needs to be very clear and explicit in what data you are working with and what you intend to do with it. A lot of the "here is how auto will help you" descriptions justify ..read more
Code Project » C / C++ / MFC
2w ago
Maybe someone can point me to a reference or provide direct experience. I'm trying to lift a VC6++ application to VS2022. Originally targeted at Xp, this will need to run under Win10 and 11. So, I thought it would also be a good idea to get it into a modern development environment.
Well, the # of warnings I am suppressing is getting concerning, but I understand what the warnings are about. Then I ran into this line of code:
"ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)"
pure mfc macro which generates "....cpp(66): warning C26454: Arithmetic overflow: '-' operation produces a negative unsi ..read more
Code Project » C / C++ / MFC
3w ago
for(int i=0;i<3;i++)
{
vector<thing*> * Nodes = new vector <thing*>();
thing * Athing = new thing();
Nodes->push_back(Athing);
//do stuff
}
do I need to delete the vector once the work is done or this is not required?
How about the things stored inside the container, do I need to delete those too or calling clear() is enough.
for(int i=0;i<3;i++)
{
vector<thing*> * Nodes = new vector <thing*>();
thing * Athing = new thing();
Nodes->push_back(Athing);
//do stuff
Nodes->clear();
delete Nodes ..read more