65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class Text
{
char * ptext;
public:
Text(char * m)
{
ptext = m;
}
char & operator [] (int position) const
{
return ptext[position];
}
};
void main()
{
const Text a("Hello");
char * p = &a[0];
cout<< p <<endl;
}

// v.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Text
{
char * ptext;
public:
Text(char * m)
{
ptext = m;
}
char operator [] (int position) const
{
return ptext[position];
}
};
int _tmain(int argc, _TCHAR* argv[])
{
const Text a("Hello");
char p = a[0];
cout<<p<<endl;
return 0;
}