error C2440: 'initializing' : cannot convert from 'class c *' to 'class c' 求指导
#include<iostream>usingnamespacestd;classc{};voidmain(){ca=newc();cout>>&a>>endl;cb=a...
#include <iostream>
using namespace std;
class c
{
};
void main()
{
c a=new c();
cout>>&a>>endl;
c b=a;
cout>>&b;
}
-Configuration: 1211 - Win32 Debug--------------------
Compiling...
1211.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(8) : error C2440: 'initializing' : cannot convert from 'class c *' to 'class c'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(9) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined op
erator
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(11) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined o
perator
Error executing cl.exe.
1211.obj - 3 error(s), 0 warning(s) 展开
using namespace std;
class c
{
};
void main()
{
c a=new c();
cout>>&a>>endl;
c b=a;
cout>>&b;
}
-Configuration: 1211 - Win32 Debug--------------------
Compiling...
1211.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(8) : error C2440: 'initializing' : cannot convert from 'class c *' to 'class c'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(9) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined op
erator
C:\Program Files\Microsoft Visual Studio\MyProjects\1211\1211.cpp(11) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined o
perator
Error executing cl.exe.
1211.obj - 3 error(s), 0 warning(s) 展开
推荐于2016-01-16 · 知道合伙人软件行家
关注
展开全部
#include <iostream>
using namespace std;
class c
{
};
void main()
{
c *a=new c();
cout<< &a <<endl;
c *b=a;
cout<< &b;
}
using namespace std;
class c
{
};
void main()
{
c *a=new c();
cout<< &a <<endl;
c *b=a;
cout<< &b;
}
更多追问追答
追问
为什么要改为指针呢?
追答
new 返回的就是 指针
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询