Cosmin
Cosmin

Reputation: 1

Errors when compiling a C++ scenario

I have created some code test and I am not able to build it without errors.When I'm trying to build the project I get the following errors :

-error C2228: left of '.FolioID' must have class/struct/union -error C2227: left of '->IsLoaded' must have point to class/struct/union/generic type -error C2227: left of '->Load' must point to class/struct/union/generic type -error C2227: left of' ->Compute' must point to class/struct/union/generic type -error C2227: left of' -> GetUnderlyingCount' must point to class/struct/union/generic type

This is the code that I used :

BEGIN_LOG("Run");
    int count;
    int portfolio;
    int *sResult;
    char MyString[1000];
    sprintf_s(MyString,"contrepartie in (select ident from tiers where ident = 10012834)");
    const CSRExtraction *myExtraction=CSRPortfolio::Extraction(MyString);
    ((CSRExtraction *)myExtraction)->Create();
    ((CSRExtraction *)myExtraction)->Load();
    ((CSRExtraction *)myExtraction)->InitialiseFolio();

    for (int f=0; f < count; f++) //folio loop
    {
        portfolio = CSRPortfolio::GetCSRPortfolio(sResult[f].FolioID,myExtraction);
        //portfolio = CSRPortfolio *GetCSRPortfolio -> sResult[] -> FolioID();
        if (portfolio == NULL)
            continue;

        if(!portfolio->IsLoaded())
        {
            portfolio->Load();
            portfolio->Compute();
        }

        int underl = portfolio->GetUnderlyingCount();
    }


    END_LOG();

Can you give me some hints, please?

Upvotes: 0

Views: 45

Answers (1)

A.Franzen
A.Franzen

Reputation: 745

Well,

sResult[f].FolioID

sResult is a pointer to int. Ints don't have members. Thus you can't access it.

Same goes for portfolio.

Only structs and classes have members.

I guess what you really want to do is something like this:

CSRPortfolio *portfolio = CSRPortfolio::GetCSRPortfolio(sResult[f],myExtraction);

Beware though, that in your example sResult is completely uninitialized. The access will thus crash.

Upvotes: 1

Related Questions