【发布时间】:2015-08-04 19:47:27
【问题描述】:
我正在尝试开发和部署一个 ASP.NET 网络服务,作为大学项目的一部分。我必须使用 Visual Studio 2005 (!!) 并且不能使用 WCF。这些是教授强加的限制。
问题是我必须声明和使用一个 complex 变量。也就是说,一个具有实部和虚部的变量。如果我包含复数,然后将变量声明为:
#include <complex>
然后在代码后面几行:
complex waterheater_actual_power;
我在尝试构建项目时收到以下错误消息:
1>WHeaterImpl.cpp
1>.\WHeaterImpl.cpp(89) : error C2146: syntax error : missing ';' before identifier 'waterheater_actual_power'
1>.\WHeaterImpl.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\WHeaterImpl.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
经过一番搜索,我发现了以下post
因此,我像以前一样包含 complex,然后以这种方式声明我的变量:
complex<double> waterheater_actual_power;
根据我的理解,这应该可以解决问题,但是在尝试构建项目时,我仍然收到一些错误消息,但这次数量较少。确切地说,这里是输出:
1>WHeaterImpl.cpp
1>.\WHeaterImpl.cpp(89) : error C2143: syntax error : missing ';' before '<'
1>.\WHeaterImpl.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
在这一点上,我应该声明我在 Visual Studio 中几乎是新手,所以我不能排除我的问题的答案非常简单的可能性。
有什么建议吗?
下面是第 1 行的代码,直到出现问题的那一行:
#include <complex>
//#include "WHeater.h"
#include "stdafx.h"
#include "WHeaterImpl.h"
#include "Global.asax.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#define TS_NEVER ((int)(((unsigned int)-1)>>1))
#define TSTAT_PRECISION 0.01
#define HEIGHT_PRECISION 0.01
#define TS_SECOND ((int)1000000000) /* duration of one second */
#define RHOWATER (62.4) // lb/cf
#define CFPGAL (0.133681) // cf/gal
#define GALPCF (7.4805195) // gal/cf
#define CWATER (0.9994) // BTU/lb/F
#define BTUPHPW (3.4120) // BTUPH/W
#define BTUPHPKW (1e3 * 3.4120) // BTUPH/kW
#define KWPBTUPH (1e-3/BTUPHPW) // kW/BTUPH
#define MWPBTUPH (1e-6/BTUPHPW) // MW/BTUPH
#define ROUNDOFF 1e-6 // numerical accuracy for zero in float comparisons
const double pi = 3.1415926535897931;
const double Cp = 1; // Btu/lbm-F
/* approximate tests */
#define AEQ(A,B,C) (fabs(A-B)<C)
#define ANE(A,B,C) (fabs(A-B)>=C)
#define ALT(A,B,C) (A<=B+C)
#define AGT(Ak,B,C) (A>=B-C)
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
// Basic characteristics defined at creation...
double Tset_curtail; ///< lower limit before we cancel curtailment [F]
double Tinlet; ///< default will be set to 60 degF
//enumeration location; ///< location of tank (inside or garage) [enum]
// enumeration heat_mode; ///< method of heating the water (gas or electric) [enum]
// Characteristics calculated from basics at creation...
double area; ///< tank cross-sectional area [ft^2]
double height; ///< tank height [ft]
double Ton; ///< cut-in temperature [F]
double Toff; ///< cut-out temperature [F]
double Cw; ///< thermal mass of water [Btu/F]
// The primary values we compute in our simultation...
double h; ///< boundary between hot and cold water layers [ft from top of tank]
double Tlower; ///< temperature in lower zone of tank (for 2-zone model) [F]
double Tlower_old;
double Tupper; ///< temperature in upper zone of tank (for 2-zone model) [F]
double Tupper_old;
double Twater; ///< temperature of whole tank (for 1-node model) [F]
double Tw; ///< water temperature [F]
double Tw_old; ///< previous water temperature, for internal_gains
double standby_load;
double time_to_transition; ///< time until next transition [in seconds]
// Convenience values (some pre-computed here and there for efficiency)...
bool heat_needed; ///< need to maintain this bit of state because of Tstat deadband...
double is_waterheater_on; ///< Simple logic for determining state of waterheater 1-on, 0-off
double tank_volume; ///< tank size [gal]
double tank_UA; ///< tank UA [BTU/hr-F]
double tank_diameter; ///< tank diameter [ft]
double water_demand; ///< water draw rate [gpm]
double water_demand_old; ///< previous water demand, needed for temperature change (reflects heat loss from hot water draw)
double heating_element_capacity; ///< rated Q of (each) heating element, input in W, converted to[Btu/hr]
double tank_setpoint; ///< setpoint T of heating element [F]
double thermostat_deadband; ///< deadband around Tset (half above, half below) [F]
double *pTair;
double *pTout;
double gas_fan_power; ///< fan power draw when a gas waterheater is burning fuel
double gas_standby_power; ///< standby power draw when a gas waterheater is NOT burning fuel
double actual_load;
double prev_load;
complex<double> waterheater_actual_power;
【问题讨论】:
-
@Sotiris 你有没有尝试通过以下方式声明 std::complex
waterheater_actual_power? -
@Sotiris 您应该在添加代码之前合并我的编辑。好吧,我现在要离开这个废话,并且不会再这样做了。您只是缺少一个
std::命名空间标识符。
标签: c++ asp.net .net web-services visual-studio