Click to See Complete Forum and Search --> : Weird C++ Syntax
Recently I came across a code having
--------------------
string FirstSymName = m_Operands[i]->GetSymbol()->GetDisplayName();
--------------------
m_Operands[i]->GetSymbol() is OK, but what is the meaninging of
GetSymbol()->GetDisplayName();
Thanks
most likely "m_Operands[i]->GetSymbol()" returns a pointer, which is then
used to call function GetDisplayName()...
<pointer>->GetDisplayName();
GetDisplayName() returns a string and assigns it to FirstSymName...
maybe this little bit of code can help you:
#include <string>
#include <iostream>
using namespace std;
class Test1
{
public:
Test1(string str){s=str;}
string ret_s(){return s;}
private:
string s;
};
class Test2
{
public:
Test2(Test1 *T){p=T;}
Test1 *ret_p(){return p;}
private:
Test1 *p;
};
void main()
{
Test1 *T1 = new Test1("Hello World");
Test2 *T2 = new Test2(T1);
string str2=T2->ret_p()->ret_s();
cout<<str2;
}
"John" <john_trivolta@planetaccess.com> wrote:
>
>Recently I came across a code having
>
>--------------------
>string FirstSymName = m_Operands[i]->GetSymbol()->GetDisplayName();
>--------------------
>m_Operands[i]->GetSymbol() is OK, but what is the meaninging of
>
>GetSymbol()->GetDisplayName();
>
>
>Thanks
Thanks a lot mic...You are right !!!
devx.com
Copyright Internet.com Inc. All Rights Reserved