C++ 将头文件添加到g++;编译程序
我是一个初学者。我在C++中做了一个图书管理系统,我想给它添加GUI。我不熟悉很多GUI应用程序。但我知道Tk库,因为我是在学习python之后学习c++的。我从互联网上下载了它。但我不知道如何将它添加到path以便g++编译器可以读取它。我还下载了一个boost库,因为它是在Tk页面上编写的,它需要它。我使用了C++ 将头文件添加到g++;编译程序,c++,terminal,compiler-errors,path,mingw,C++,Terminal,Compiler Errors,Path,Mingw,我是一个初学者。我在C++中做了一个图书管理系统,我想给它添加GUI。我不熟悉很多GUI应用程序。但我知道Tk库,因为我是在学习python之后学习c++的。我从互联网上下载了它。但我不知道如何将它添加到path以便g++编译器可以读取它。我还下载了一个boost库,因为它是在Tk页面上编写的,它需要它。我使用了g++-i[dir]< /Cord>命令,但我没有将库添加到G++可以读取的地方。它总是显示“代码> G++.exe:致命错误:没有输入文件< /代码>。我在 Windows 。还请写如
g++-i[dir]< /Cord>命令,但我没有将库添加到G++可以读取的地方。它总是显示“代码> G++.exe:致命错误:没有输入文件< /代码>。我在<强> Windows 。还请写如何在终端中写入路径。我使用的是MINW编译器,用于C++。< / P>
我的代码
#include<iostream>
using namespace std;
#include<string>
using namespace std;
#include<map>
using namespace std;
#include <vector>
using namespace std;
class Library
{
private:
vector <string> all_books;//All books in library
map <string,string> books_lended;//bookname:ownername
string email;//Owner email
string password;//Owner password
string add_new_book(string);//bookname as input
string delete_book(string);//Bookname as input
string booklenderdict();//Return string of dict book_lended
string allbookslist();//Returns list of allbooks in library
public:
string library_name;//Name of library.
vector <string> books_available;//Available books in library
Library(string , string , string , vector< string > );//Constructor libraryname,email,password,books in library
string return_book(string,string);//Returns the book
string book_lend(string,string);//Lends the book
string admin(string,int,string);
};
Library :: Library(string libraryname, string email1, string password1, vector<string> books){
/* Sets the variables*/
library_name=libraryname;
email=email1;
password=password1;
books_available=books;
all_books=books;
}
string Library:: add_new_book(string bookname){
/*Adds new book to the library
false-->Book already exists
true -->Book added
*/
for (auto item : all_books){
//Checking if the book already exists
if(item==bookname){
return "false";
}
}
all_books.push_back(bookname);
books_available.push_back(bookname);
return "true";
}
string Library :: delete_book(string bookname){
/*Deletes the book from the library
"false"-->book not exists
"true"--->book deleted
"null"-->book exists but not available now
*/
int i=0;
for(auto item: all_books){
//Checking if the book exits
if (item==bookname){
int k=0;
for (auto items: books_available){
//Checking if the book is available
if (items==bookname){
//Deleting the book
books_available.erase(books_available.begin()+k);
all_books.erase(all_books.begin()+i);
return "true";//book deleted
}k++;
}return "null";//book currently not availble
}i++;
}return "false";//Book not exists
}
string Library :: return_book(string bookname,string borrowername){
/*Returns the books the user has taken
true:Boork returnes
false-->Incorrect book name or book not borrowed
null-->Owner not correct
*/
map <string,string>::iterator it;
for(it=books_lended.begin();it!=books_lended.end();it++){
//Chcek if the book is being owned
if(it->first==bookname){
if(it->second==borrowername){
//Check if the borrower name is correct
books_available.push_back(bookname);
books_lended.erase(bookname);
return "true";
}return "null";
}
}return "false";
}
string Library :: book_lend(string bookname,string borrowername){
/*Lend the book
true:booklended succesfully
false:Book not availble
null:book not exists
*/
int k=0;
for (auto items:books_available){
/*Checking if the book is available or not*/
if (items==bookname){
books_available.erase(books_available.begin()+k);
books_lended[bookname]=borrowername;
return "true";
}
}
for (auto item:all_books){
//Checking if book exists in library
if(item==bookname){
return "false";
}
}return "null";
}
string Library :: booklenderdict(){
//Returns string of dictionary of books lended record
map <string,string>::iterator it;
string dictionary="{";
for(it=books_lended.begin();it!=books_lended.end();it++){
dictionary.append(it->first);
dictionary.append(":");
dictionary.append(it->second);
dictionary.append(",");
}
dictionary.pop_back();
dictionary.append("}");
return dictionary;
}
string Library::allbookslist(){
//Returns string of list of allbooks in library
string list="[";
for (auto item:all_books){
list.append(item);
list.append(",");
}
list.pop_back();//Removing last comma
list.append("]");
return list;
}
string Library :: admin(string password1,int choice,string bookname="k"){
/*Admin method to return personal details
following choices are available
1-->add new book
2-->delete book
3-->show email
4-->return dictionary of borrowers
5-->return list of books in library
else return false
*/
if (password1==password){//Checking if password is correct
if (choice==1){
return add_new_book(bookname);
}
if (choice==2){
return delete_book(bookname);
}
if(choice==3){
return email;
}
if (choice==4){
return booklenderdict();
}
if (choice==5){
return allbookslist();
}
}
return "false";
}
int main(){
return 0;
}```
#包括
使用名称空间std;
#包括
使用名称空间std;
#包括
使用名称空间std;
#包括
使用名称空间std;
类库
{
私人:
矢量所有_图书;//图书馆中的所有图书
地图册\u借出;//书名:ownername
字符串电子邮件;//所有者电子邮件
字符串密码;//所有者密码
string add_new_book(string);//bookname作为输入
string delete_book(string);//Bookname作为输入
string booklenderdict();//返回借出的dict book的字符串
string allbookslist();//返回库中所有书籍的列表
公众:
string library_name;//库的名称。
矢量书\u可用;//图书馆中可用的书
库(string,string,string,vector);//构造函数库名,电子邮件,密码,库中的书籍
string return_book(string,string);//返回书本
string book_lend(string,string);//借书
字符串管理(字符串、整型、字符串);
};
Library::Library(字符串libraryname、字符串email1、字符串password1、矢量书){
/*设置变量*/
图书馆名称=图书馆名称;
email=email1;
密码=密码1;
可用书籍=书籍;
所有书籍=书籍;
}
字符串库::添加新的书籍(字符串书名){
/*将新书添加到图书馆
错误-->书本已存在
添加了“真-->书本”
*/
用于(自动项目:所有书籍){
//检查该书是否已存在
如果(项目==书名){
返回“false”;
}
}
所有书籍。推回(书名);
图书可用。向后推(图书名称);
返回“真”;
}
string Library::delete_book(string bookname){
/*从库中删除该书
“false”-->本书不存在
“正确”-->已删除书本
“null”-->书本存在,但现在不可用
*/
int i=0;
用于(自动项目:所有书籍){
//检查书是否存在
如果(项目==书名){
int k=0;
用于(自动项目:可用的图书){
//检查是否有这本书
如果(项目==书名){
//删除该书
可用图书。擦除(可用图书。开始()+k);
所有书籍。擦除(所有书籍。开始()+i);
返回“true”;//图书已删除
}k++;
}返回“null”;//书本当前不可用
}i++;
}返回“false”;//书本不存在
}
stringlibrary::return_book(stringbookname、stringlowername){
/*返回用户已获取的书籍
真的:布尔克回来了
false-->图书名称不正确或图书未借用
空-->所有者不正确
*/
对它进行迭代器;
for(it=books\u lended.begin();it!=books\u lended.end();it++){
//如果这本书是被拥有的
if(it->first==bookname){
if(it->second==借用名称){
//检查借款人名称是否正确
图书可用。向后推(图书名称);
借出的书。擦除(书名);
返回“真”;
}返回“null”;
}
}返回“false”;
}
string Library::book_lend(string bookname、string lowername){
/*借书
正确:图书出借成功
错误:本书不可用
空:书本不存在
*/
int k=0;
用于(自动项目:可用的图书){
/*检查是否有这本书*/
如果(项目==书名){
可用图书。擦除(可用图书。开始()+k);
借出的书[书名]=借书人姓名;
返回“真”;
}
}
用于(自动项目:所有书籍){
//检查图书馆是否有这本书
如果(项目==书名){
返回“false”;
}
}返回“null”;
}
字符串库::booklenderdict(){
//返回借出图书记录的字典字符串
对它进行迭代器;
字符串字典=“{”;
for(it=books\u lended.begin();it!=books\u lended.end();it++){
dictionary.append(it->first);
字典。附加(“:”);
dictionary.append(it->second);
字典。追加(“,”);
}
dictionary.pop_back();
dictionary.append(“}”);
返回字典;
}
字符串库::allbookslist(){
//返回库中所有图书的列表字符串
字符串列表=“[”;
用于(自动项目:所有书籍){
列表。追加(项目);
列表。追加(“,”);
}
list.pop_back();//删除最后一个逗号
列表。附加(“]”);
退货清单;
}
字符串库::admin(字符串密码1,int选项,字符串bookname=“k”){
/*返回个人详细信息的Admin方法
以下选项可用
1-->添加新书
2-->删除书本
3-->显示电子邮件
4-->借贷者返回字典
5-->图书馆图书归还清单
否则返回false
*/
if(password1==password){//检查密码是否正确
如果(选项==1){
返回新增图书(图书名称);
}
如果(选项==2){
返回删除书(书名);
}
如果(选项==3){
回复邮件;
}
如果(选项==4){
返回booklenderdict();
}
如果(选项==5){
返回allbookslist();
}
}
R