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

首頁 > 學院 > 開發設計 > 正文

Visual Stuido (1): 跨項目調用 同一個solution下面不同project之間的方法調用

2019-11-11 04:07:38
字體:
來源:轉載
供稿:網友

因為本人自己需要在同一個solution下面做多個PRoject,我用的是VS2015, 語言C++。 首先創建兩個project,其中HelloMultiproject作為啟動的project,它是exe類型;AnotherProject是dll類型的,如圖: 這里寫圖片描述

有兩種方式來從一個project調用另一個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;}
上一篇:將字符串轉換為數字

下一篇:內聯函數

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿克陶县| 鞍山市| 五华县| 莱州市| 和静县| 南昌县| 白城市| 开封市| 鹤壁市| 马龙县| 寿阳县| 喀喇沁旗| 青浦区| 河间市| 金溪县| 九江市| 兴宁市| 丰城市| 嘉善县| 江华| 合山市| 当涂县| 台中县| 西丰县| 大姚县| 顺义区| 涿鹿县| 东台市| 南澳县| 荣成市| 康定县| 吉木萨尔县| 怀宁县| 永宁县| 沅江市| 阳曲县| 沾化县| 井研县| 兴山县| 清水河县| 瑞昌市|