Microsoft visual Studio 2010版 求大神解决,急 5
#include<iostream>usingnamespacestd;classshape{public:virtualfloatarea()=0;virtualvoi...
#include<iostream>using namespace std;class shape{public: virtual float area()=0; virtual void print()=0;};class rectangele:public shape{private: float a,b;public: rectangele(){} rectangele(int n,int m){a=n;b=m;} float area(){return a*b;} void print(){cout<<"长方形面积为:"<<area()<<endl;}};class circle:public shape{private: float r;public: circle(float a){r=a;} float area(){return r*r*3.14;} void print(){cout<<"圆的面积"<<area()<<endl;}};class square:public rectangele{private: float s;public: square(float a){s=a;} float area(){return s*s;} void print(){cout<<"正方形面积:"<<area()<<endl;}};void main(){ shape *p; p=new rectangele(3,4); p->print (); p=new circle(5); p->print (); p=new square(4); p->print (); system("pause");}
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
1>c:\users\me\documents\visual studio 2010\Projects\6.1(2.1)\Debug\6.1(2.1).exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
1>c:\users\me\documents\visual studio 2010\Projects\6.1(2.1)\Debug\6.1(2.1).exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
1个回答
展开全部
你选错工程类型了,应该建立console
追问
啥,不是很懂,刚开始学的
追答
菜单上不是有新建工程吗,重新建一个console工程。把下面的代码复制进去就好。这里是多态的应用,好像不是初学的内容吧?
#include<iostream>
using namespace std;
class shape
{
public:
virtual float area() = 0;
virtual void print() = 0;
};
class rectangele :public shape
{
private:
float a, b;
public:
rectangele()
{}
rectangele(int n, int m)
{
a = n;
b = m;
}
float area()
{
return a * b;
}
void print()
{
cout << "长方形面积为:" << area() << endl;
}
};
class circle :public shape
{
private:
float r;
public:
circle(float a)
{
r = a;
}
float area()
{
return r * r*3.14;
}
void print()
{
cout << "圆的面积" << area() << endl;
}
};
class square :public rectangele
{
private:
float s;
public:
square(float a)
{
s = a;
}
float area()
{
return s * s;
}
void print()
{
cout << "正方形面积:" << area() << endl;
}
};
void main()
{
shape *p;
p = new rectangele(3, 4);
p->print();
p = new circle(5);
p->print();
p = new square(4);
p->print();
system("pause");
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询