我无法在其他.cpp文件上进行声明, 我尝试过,但找不到解决方案。我试图制作一个电影系统,并想在其他文件上声明内容。 有可能吗?
这是我的代码:
File "C:/Users/27357/Desktop/test.py", line 2, in <module>
import pandas
File "C:\python\lib\site-packages\pandas\__init__.py", line 55, in <module>
from pandas.core.api import (
File "C:\python\lib\site-packages\pandas\core\api.py", line 24, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "C:\python\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
from pandas.core.groupby.generic import ( # noqa: F401
File "C:\python\lib\site-packages\pandas\core\groupby\generic.py", line 44, in <module>
from pandas.core.frame import DataFrame
File "C:\python\lib\site-packages\pandas\core\frame.py", line 88, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "C:\python\lib\site-packages\pandas\core\generic.py", line 70, in <module>
from pandas.io.formats.format import DataFrameFormatter, format_percentiles
File "C:\python\lib\site-packages\pandas\io\formats\format.py", line 48, in <module>
from pandas.io.common import _expand_user, _stringify_path
File "C:\python\lib\site-packages\pandas\io\common.py", line 512, in <module>
def UnicodeReader(f, dialect=csv.excel, encoding="utf-8", **kwds):
AttributeError: module 'csv' has no attribute 'excel'
答案 0 :(得分:0)
如果您是要在头文件中声明该结构而不是在main.cpp中声明,请制作一个头文件并说您将其命名为MovieItem.h
#ifndef Info_H
#define Info_H
struct Info{
string movie1,movie2,movie3,movie4; //MOVIE CHANGES
movie1 = "Frozen II";
movie2 = "Ip man 4";
movie3 = "The Cave";
movie4 = "Ejen Ali";
int Hall1,Hall2,Hall3,Hall4; //HALL NUM (???)
Hall1 = 1;
Hall2 = 2;
Hall3 = 3;
Hall4 = 4;
string Time1,Time2,Time3,Time4; //TIME CHANGES
Time1 = " 8.00AM";
Time2 = "10.00AM";
Time3 = " 2.00PM";
Time4 = " 6.00PM";
double price1,price2,price3,price4 ; //PRICE CHANGES
price1= 10;
price2 = 15;
price3 = 8;
price4 = 10;
};
#endif
使用
在您的main.cpp中包含此标头#include "MovieItem.h"
然后,如@shubhgkr所述,在您的源代码中使用
struct Info Item1;