不知错在哪了。。。

来源:百度知道 编辑:UC知道 时间:2024/05/18 05:53:41
#include<iostream>
using namespace std;
class Publication
{

char *cTitle;
float fPrice;

public:
void getData(char *cTitle,float fPrice)
{
this->cTitle=cTitle;
this->fPrice=fPrice;
}
void putData()
{
cout<<"Title is :"<<cTitle<<endl;
cout<<"Price is :"<<fPrice<<endl;
}

};

int main()
{
//Publication *Ptr; //报错:"fetal error: 使用未定义的指针 'Ptr' "
Publication *Ptr = new Publication ; //这样写也报错 : fatal error LNK1168: cannot open E:\projects\滞后联编\Debug\滞后联编.exe for writing
Ptr->getData(" c++",51);
Ptr->putData();
delete Ptr;
return 0;
}

楼主上面那个程序最后的主函数int main()
{
少了一个}!!!
楼主用的什么编译器?
能通过编译呀!!!visual c++ 6.0/.net2005都能通过的!
在dev-c 4.9.8.0上也可以的!!

没有发现任何错误,编译通过了。

Title is : c++
Price is :51