国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Visual Stuido (1): 跨項(xiàng)目調(diào)用 同一個(gè)solution下面不同project之間的方法調(diào)用

2019-11-11 03:34:54
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

因?yàn)楸救俗约盒枰谕粋€(gè)solution下面做多個(gè)PRoject,我用的是VS2015, 語(yǔ)言C++。 首先創(chuàng)建兩個(gè)project,其中HelloMultiproject作為啟動(dòng)的project,它是exe類型;AnotherProject是dll類型的,如圖: 這里寫圖片描述

有兩種方式來(lái)從一個(gè)project調(diào)用另一個(gè)project的方法(或者類)。

1. 如果AnotherProject的配置Configuration Type是Dynamic Library(.dll)

使用dllexportdllimport AnotherProject的配置: 這里寫圖片描述 HelloMultiProject不需要配置。

// Another project//FindMax.h#pragma once#include "stdafx.h"_declspec(dllexport) int findMax(int i, int j);//FindMax.cpp#include "stdafx.h"#include "FindMax.h"int findMax(int i, int j){ return i > j ? i : j;}// HelloMultiProject// HelloMultiProject.cpp : Defines the entry point for the console application.//#include "stdafx.h"_declspec(dllimport) int findMax(int i, int j);int main(){ findMax(1, 2); return 0;}

2. 如果AnotherProject的配置Configuration Type是Static Library(.lib)

AnotherProject的配置: 這里寫圖片描述

HelloMultiProject的配置: 這里寫圖片描述

// Another project//FindMax.h#pragma once#include "stdafx.h"int findMax(int i, int j);//FindMax.cpp#include "stdafx.h"#include "FindMax.h"int findMax(int i, int j){ return i > j ? i : j;}// HelloMultiProject// HelloMultiProject.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "FindMax.h"int main(){ findMax(1, 2); return 0;}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 铁岭县| 莱州市| 扶沟县| 盐边县| 肃北| 册亨县| 江达县| 钟祥市| 托克托县| 灵武市| 永吉县| 灵璧县| 安阳县| 黎平县| 金秀| 丰县| 夹江县| 五华县| 封丘县| 财经| 漳平市| 山阴县| 图木舒克市| 三门峡市| 甘孜县| 齐齐哈尔市| 镇宁| 中西区| 苏州市| 邳州市| 曲阳县| 正镶白旗| 渭南市| 义乌市| 扎赉特旗| 湟中县| 上犹县| 宁晋县| 岑溪市| 中宁县| 泾川县|