One solution has two projects. One project calls the functions of the other project.

Source: Internet
Author: User

Two projects are test1 and test2 respectively. Two Functions in test1 are called by test2. The usage is as follows:

// Test1.h

Intadd (intx, inty );

Intsubstract (intx, inty );

// Test1.cpp

# Include "test1.h"

Intadd (intx, inty)

{
Returnx + y;
}

Intsubstract (intx, inty)

{
Returnx-y;
}

Change the configuration type of test1 to static library. lib ).

// Test2.cpp

# Include <iostream>
// # Pragmacomment (lib, "test1.lib ")
# Include "D: \ User \ Documents \ VisualStudio2012 \ Projects \ test1 \ test1 \ test1.h" // Add the path test1.h. Otherwise, the header file cannot be found.
Usingnamespacestd;

Intmain ()

{
Cout <add (3, 4) <endl;
Cout <substract (5, 3) <endl;
Return0;

}

Set the project dependency of test2 to test1, right-click the test2 project, and add reference test1 for debugging.

This article is from the "cabbage" blog, please be sure to keep this source http://zhengyongkun.blog.51cto.com/1163218/1299828

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.