Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I created a vs2005 win32 console project, and a static library was imported to my project.

1. In the lib, a class 'CTST' had been definded,lib name is 'ctst.lib';
2. It's head file is Ctst.h;
3. I use it like below:
C++
//before this, I have already imported the libary to the project.
#include "Ctst.h" //just for including CTST type declaration:
CTST* newTst = new CTST();//call construction

if(newTst->Fun1())//call a funtion in CTST,Fun1 returns boolean
{
    printf("hello Fun1 1111\n ");
}

if(!newTst->Fun1() || newTst->Fun1())//Fun1 returns boolean type value
{
    printf("hello 2222 \n ");
}
//... Other use of the libary.

delete newTst;

4. When I stepped into the code above, I found that it can be compiled, but not able for me to step into any code in the libary, and funtions used in ctst.lib in my project had no effect at all.

5. It prints like below:
hello 2222

6. I was locked into this problem, Is there any solutions for me ?
Thanks in advance!
Posted

Please check that you compiled both, your main program and the library in DEBUG configuration.

It looks like your Fun1 function is returning false. That explains the output.
 
Share this answer
 
C++
if(newTst->Fun1())//call a funtion in CTST,Fun1 returns boolean
    {
        printf("hello Fun1 1111\n ");
    }
 
    if(!newTst->Fun1() || newTst->Fun1())//Fun1 returns boolean type value
    {
        printf("hello 2222 \n ");
    }


From the first if statement, it is obvious that newTst->Fun1() returns false, so only in the next if statement succeeded and the result is printed as stated by you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900