Compile Problem (Compiler Error C2475) 
Author Message
 Compile Problem (Compiler Error C2475)

I have define two class as :
//--------------------------
class A {
    map<int,CStrinaArray *> m_map;

public:
    const CStringArray * GetArray(int n) { return m_map[n]; };

Quote:
};

//--------------------------
class B {
    A *m_A;

public:
    void UseA(int n);

Quote:
};

//--------------------------

Then I call the function as:

void B::UseA(int n)
{
    const CStringArray *pArr=m_A->GetArray(n);

Quote:
};

I get error as:
error C2475: 'B::GetArray' : forming a pointer-to-member requires explicit
use of the address-of operator ('&') and a qualified name

error C2109: subscript requires array or pointer type
----------------------------------------------------------------------------
----
I change the code as:

void B::UseA(int n)
{
    const CStringArray A::*pArr=m_A->CStringArray *A::GetArray(n);

Quote:
};

another error as:
error C2039: 'CStringArray' : is not a member of 'A'
----------------------------------------------------------------------------
----
God,
Who can tell me how to resolve the problem?




Thu, 07 Apr 2005 12:37:24 GMT  
 Compile Problem (Compiler Error C2475)
Either the code you show is not the same as the one in your program, or
the problem is in the code you don't show. Show a small compilable
sample that still reproduces the problem. The program below compiles
without errors:

#include <map>
using namespace std;

class CStringArray {};

class A {
    map<int,CStringArray *> m_map;
public:
    const CStringArray * GetArray(int n) { return m_map[n]; }

Quote:
};

class B {
    A *m_A;
public:
    void UseA(int n);

Quote:
};

void B::UseA(int n)
{
    const CStringArray *pArr=m_A->GetArray(n);

Quote:
};

int main()
{
    B b;
    b.UseA(0);
    return 0;

Quote:
}

--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I have define two class as :
> //--------------------------
> class A {
>     map<int,CStrinaArray *> m_map;

> public:
>     const CStringArray * GetArray(int n) { return m_map[n]; };
> };
> //--------------------------
> class B {
>     A *m_A;

> public:
>     void UseA(int n);
> };
> //--------------------------

> Then I call the function as:

> void B::UseA(int n)
> {
>     const CStringArray *pArr=m_A->GetArray(n);
> };

> I get error as:
> error C2475: 'B::GetArray' : forming a pointer-to-member requires
explicit
> use of the address-of operator ('&') and a qualified name

> error C2109: subscript requires array or pointer type
> ----------------------------------------------------------------------
------
> ----
> I change the code as:

> void B::UseA(int n)
> {
>     const CStringArray A::*pArr=m_A->CStringArray *A::GetArray(n);
> };

> another error as:
> error C2039: 'CStringArray' : is not a member of 'A'
> ----------------------------------------------------------------------
------
> ----
> God,
> Who can tell me how to resolve the problem?





Fri, 08 Apr 2005 22:04:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Compile Problem (Compiler Error C2475)

2. Internal Compiler Error C1001 (in VC++) when compiling a Dialog based App

3. VC++6.0/SP3 Compiler Error: INTERNAL COMPILER ERROR

4. Problem compiling my compiler...

5. Problem when compiling bison generated C file using msvc cl compiler (with optimisation on

6. VC7 Link error compiling ADO code (no problem in VC6)

7. interfaces and base class problem compile error.

8. Compiling problems (Symbol referencing errors)

9. help: compile error problem

10. VC++1.5 Compile error U1073 problem

11. VC7 Link error compiling ADO code (no problem in VC6)

12. VC 5.0 Compile Errors (compiles fine with 4.2)

 

 
Powered by phpBB® Forum Software