函数调用时,返回的指针可以做左值么
class Account{
public:
....
static Account *First();
protected:
static Account *pFirst;
.........
}
Account * Account::First()
{
return pFirst;
}
void main()
{
..........
pS->First()=NULL//这是对的么??
}
#include<iostream>
using namespace std;
class Test
{
protected:
static int n;
public:
Test(){ n++;}
static int getN(){ return n;}
~Test(){ n--;}
};
int Test::n = 0;
int main()
{
Test test1, test2;
// Test::getN() = 3; you will see it is not allowed
cout<<Test::getN()<<endl;
return 0;
}