c++对象指针问题
本帖最后由 erool950 于 2015-1-31 13:33 编辑#include<iostream>
using namespace std;
class B
{
public:
B()
{
length=1; width=1; height=1;
cout<<"B constructor is executed!"<<endl;
}
void show()
{
cout<<"length:"<<length<<endl;
cout<<"width:"<<width<<endl;
cout<<"height"<<height<<endl;
}
~B()
{
cout<<"asdjoasdj"<<endl;
}
private:
float length,width,height;
};
int main()
{
B b;
B * p=&b;
cout<<(*p).show()<<endl;
return 0;
}
提示 cout<<(*p).show()<<endl;这句有问题 no match for 'operator<<' in 'std::cout << p->B::show()'
int main()
{
B b;
B * p=&b;
(*p).show();
return 0;
}
页:
[1]