#include <iostream>
#include <cstring>
using namespace std;
struct STRUCT
{
string hello;
};
int main()
{
STRUCT *str=new STRUCT;
str->hello="Hello";//或者可以写成: (*str).hello="Hello"
cout<<str->hello<<endl;//或者可以写成: cout<<(*str).hello<<endl;
delete str;
return 0;
}
|
#include <iostream>
#include <cstring>
using namespace std;
class CLASS
{
public:
string hello;
};
int main()
{
CLASS *str=new CLASS;
str->hello="Hello";//同理
cout<<str->hello<<endl;//同理
delete str;
return 0;
}
|