编译器报错: error LNK2019: 无法解析的外部符号 "public: __thiscall Scene::~Scene(void)" ……
#include<iostream>#include<vector>#include<map>#include<string>#include<cmath>usingna...
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
using namespace std;
class Scene{ //场景类
private:
string SceneName; //场景名字
vector<string> Voice; //场景包含的声音名称
vector<double> Probability; //在此场景下,假设条件独立,各声音出现概率
int num; //包含声音个数
map<string,double> VP; //定义声音和出现概率的映射
map<string,double>::iterator p;//定义映射的迭代器
double ScenePro;
public:
Scene(string NN,double X){
SceneName=NN;
ScenePro=X;
num=0;
}
~Scene();
void SetVoiceName(string NN){ //插入数据
Voice.push_back (NN);
}
void SetProbability(double NN){
Probability.push_back (NN);
}
void SetNum(int NN){
num=NN;
}
void SetVP(){ //构建映射
for(int i=0;i<num;i++)
{
VP.insert (make_pair(Voice[i],Probability[i]));
}
}
double getProbability(string Name){ //获取声音概率
int i=0;
SetVP();
for(p=VP.begin ();p!=VP.end ();p++)
{
if(i!=num)
{
if(p->first==Name)
{return p->second;}
i++;
}
else return 0;
}
return false;
}
string getSceneName(){
return SceneName;
}
};
void main()
{
string NN;
string name[]={"舞会"};
Scene V1(name[0],0.4);
string V1N[]={"对话","音乐","碰杯","关门"};
double V1P[]={0.6,0.9,0.3,0.1};
for(int i=0;i<4;i++)
{
V1.SetVoiceName(V1N[0]);
V1.SetProbability(V1P[i]);
}
cout<<"输入要查询的声音事件名"<<endl;
cin>>NN;
cout<<V1.getSceneName()<<"\t";
cout<<V1.getProbability(NN)<<endl;
} 展开
#include <vector>
#include <map>
#include <string>
#include <cmath>
using namespace std;
class Scene{ //场景类
private:
string SceneName; //场景名字
vector<string> Voice; //场景包含的声音名称
vector<double> Probability; //在此场景下,假设条件独立,各声音出现概率
int num; //包含声音个数
map<string,double> VP; //定义声音和出现概率的映射
map<string,double>::iterator p;//定义映射的迭代器
double ScenePro;
public:
Scene(string NN,double X){
SceneName=NN;
ScenePro=X;
num=0;
}
~Scene();
void SetVoiceName(string NN){ //插入数据
Voice.push_back (NN);
}
void SetProbability(double NN){
Probability.push_back (NN);
}
void SetNum(int NN){
num=NN;
}
void SetVP(){ //构建映射
for(int i=0;i<num;i++)
{
VP.insert (make_pair(Voice[i],Probability[i]));
}
}
double getProbability(string Name){ //获取声音概率
int i=0;
SetVP();
for(p=VP.begin ();p!=VP.end ();p++)
{
if(i!=num)
{
if(p->first==Name)
{return p->second;}
i++;
}
else return 0;
}
return false;
}
string getSceneName(){
return SceneName;
}
};
void main()
{
string NN;
string name[]={"舞会"};
Scene V1(name[0],0.4);
string V1N[]={"对话","音乐","碰杯","关门"};
double V1P[]={0.6,0.9,0.3,0.1};
for(int i=0;i<4;i++)
{
V1.SetVoiceName(V1N[0]);
V1.SetProbability(V1P[i]);
}
cout<<"输入要查询的声音事件名"<<endl;
cin>>NN;
cout<<V1.getSceneName()<<"\t";
cout<<V1.getProbability(NN)<<endl;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询